I have the following Auto Property
[DefaultValue(true)] public bool RetrieveAllInfo { get; set; }
when I try to use it inside the code i find the default false for is false
I assume this is the default value to a bool
variable, does anyone have a clue what is wrong!?
A member's default value is typically its initial value. From this, you may conclude that if you set the DefaultValue attribute for a property, the property is initialized to that value. However, you should set the property's DefaultValue attribute equal to its initialized value.
Right-click the control that you want to change, and then click Properties or press F4. Click the All tab in the property sheet, locate the Default Value property, and then enter your default value. Press CTRL+S to save your changes.
The DefaultValue attribute is only used to tell the Visual Studio Designers (for example when designing a form) what the default value of a property is. It doesn't set the actual default value of the attribute in code.
More info here: http://support.microsoft.com/kb/311339
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