Answer the question
In order to leave comments, you need to log in
How do private properties work in C#?
There is this code:
class SomeClass
{
private bool BoolTest = true;
public void SomeFunc()
{
SomeClass sc = new SomeClass();
sc.BoolTest = false; // почему-то доступное свойство
}
}
class AccessTester
{
public void TestPrivate()
{
SomeClass sc = new SomeClass();
//sc.boolTest = false; конечно недоступное свойство
}
}
Answer the question
In order to leave comments, you need to log in
The property can also be available for nested classes of the same type.
Tyts
Nested types in the same body can also access those private members.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question