Linked Questions

13 votes
3 answers
2k views

Possible Duplicate: Why are my privates accessible? Why are private fields private to the type, not the instance? Most probably I am missing an obvious fact but I cannot really see the reason: ...
pencilCake's user avatar
  • 53.8k
5 votes
6 answers
251 views

Possible Duplicate: Why are private fields private to the type, not the instance? Consider the following class: public class Test { protected string name; private DateTime dateTime; ...
Kees C. Bakker's user avatar
3 votes
4 answers
311 views

public class Class1 { private object field; public Class1(Class1 class1) { this.field = class1.field; } private void Func(Class1 class1) { this.field = class1....
anth's user avatar
  • 1,934
0 votes
1 answer
174 views

Possible Duplicate: Why are private fields private to the type, not the instance? Consider the following code: using System; using System.Collections.Generic; using System.Linq; using System.Text;...
Vaughan Hilts's user avatar
21 votes
5 answers
1k views

I have this class: class C { private String msg; public void F(C obj, String arg) { obj.msg = arg; // this is strange, the msg shouldn't be accessible here. } public ...
smwikipedia's user avatar
28 votes
3 answers
8k views

I don't know if the question is descriptive enough but why and how does this behaviour exist?: public class Layer { public string Name { get; set; } private IEnumerable<Layer> children;...
Joan Venge's user avatar
  • 334k
28 votes
2 answers
3k views

class TestClass { private string _privateString = "hello"; void ChangeData() { TestClass otherTestClass = new TestClass(); otherTestClass._privateString = "world"; } } ...
Michael Low's user avatar
  • 24.5k
7 votes
4 answers
2k views

While cleaning some code today written by someone else, I changed the access modifier from Public to Private on a class variable/member/field. I expected a long list of compiler errors that I use to "...
AMissico's user avatar
  • 21.8k
4 votes
5 answers
415 views

I have the following code: public class PersonInitializer { private Person _person; public static Person LoadFromFile(string path) { PersonInitializer x = new PersonInitializer();...
Ian's user avatar
  • 5,755
9 votes
2 answers
1k views

(This question is a follow-up to C# accessing protected member in derived class) I have the following code snippet: public class Fox { protected string FurColor; private string furType; ...
Yippie-Ki-Yay's user avatar
1 vote
2 answers
127 views

class TestMemberOuter1{ private int data=30; class Inner{ void msg(){System.out.println("data is "+data);} } void display(){ Inner in=new Inner(); in.msg(); } public static void main(...
del_champ's user avatar
  • 179
2 votes
3 answers
130 views

guys,thanks for your time. As we known,the key words 'Private' and 'Protected' are very useful to keep some methods,fields,properties from invalid accessing outside the class.But I had got a problem ...
Claw's user avatar
  • 474