Could someone tell me the difference between
static public
public static
and
private int _myin = 0
public int MyInt
{
get{ return _myInt; }
private set {_myInt = value; }
}
the private set part is what I want to know
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The first 2 are no different, you can order the modifiers however you like, though this is more common:
The second, it means that the property can only be set within the class, but can get gotten publicly, by anyone with a reference.
E.g. this only works inside the class:
But this works anywhere:
And as another example, this would fail: