It is okay to use this in code (in the mvc 3 context or any other context) :
protected String test { get; set; }
Would like to hear why it is and why it is not if you have any of those answers.
Thanks.
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.
It is simply a convenience.
All it does is remove boiler plate code for you, since it really is equivalent to
So, when that’s all it is, use magic get set.
When you need to do something more funky, then implement the getsetters.
For example, in MVC, I often want to use Enums for my properties, but it is not supported by CodeFirst. So, I do this:
And this populates my database as expected.