I tried to do this:
public int Property {get; private set;}
It underlines the “set” and says this:
auto implemented accessor never set
It lets me compile but I am wondering if this effects anything or what is the deal with it?
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.
What you have is valid syntax. You are getting the warning because nothing is setting a value to the property (ie. the setter is not being used anywhere).
If nothing is using the setter, then the property will always have its default value, in which case you should question the value of having the property there in the first place.