class TestClass
{
private string _privateString = \"hello\";
void ChangeData()
{
TestClass otherTestClass = new TestClass();
otherTestCla
Private members are accessible to any code within the program text of that class (including within nested types). It has nothing to do with which instance of the class you're dealing with.
I don't believe this violates encapsulation - the API is still separated from the implementation, but the implementation "knows" about itself regardless of which instance it's looking at.
I believe that in some other languages this isn't how accessibility works, but it definitely is for C# and Java. (Java has slightly different rules about what can access private members, but the translated code for what you've written would still work.)
This is because C# enforces class-level privacy and not object-level privacy.
Most mainstream languages enforce the same policy, i.e. C#, C++ and Java. I think the reason are:
1) because developers are accustomed to that kind of policy;
2) because object-level privacy would become much too tedious in return of very few advantages.