[C#] Properties question
Go to solution
Solved by madknight3,
Simply use the automatic property whenever you don't add any more code. If you do, use the long version. When you do use the long version because you're adding in more code, the getter should be kept simple and shouldn't throw exceptions, while the setter can (source).
Also, if anyone wonders what the difference is between an automatic property and a simple public field
public int foo { get; set; }public int bar;
then see this answer.

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now