Possible Duplicate:
How do you give a C# Auto-Property a default value?
Hi all:
If I want to add default value, says 60, to following property for a class, what is the most convenient way in C#3.0
public int someSetting { get; set; }
You need to initialize it in all constructors.
Put it in the parameterless constructor, that's what I'd do.
Edit: Yes, I guess what I mean by the above is any constructor where the parameter in question is not passed in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With