Snippets:
private double memberVal;
public double MemberVal
{
get { return memberVal; }
set { memberVal= value; }
}
and
public double MemberVal
{
get; set;
}
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.
No, but now they are the same
and
Update
Except – as pointed out by Johannes Rössel – that you can access the field from code in the first case but not in the latter 🙂 –
Meaning that in the first code sample, within your class you can directly set the backing member for the property (i.e.
private double memberVal1e.g.memberVal = 1.1;), where in the second, there is still a private backing member for the property, but it’s now invisible.You can only access it through the property.