I am new to C#.
private string m;
public string M { get { return m; } }
Is this kind of a getter/setter in C# like Java?
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.
This part is a field:
This part is a read-only property that returns the value of the
mfield:You could make this a read-write property like so:
Or you could have more complex logic in there:
Basically, fields are only good at holding things, while properties are more like methods and can introduce logic.