Default value for public attributes

Posted by Danny Chen on Stack Overflow See other posts from Stack Overflow or by Danny Chen
Published on 2010-06-02T02:46:16Z Indexed on 2010/06/02 2:53 UTC
Read the original article Hit count: 269

Filed under:
|

I have a public attribute in some class. I want a default value -1 for this attribute without an private variable like _MyAttr(because too many attributes, i won't add them one by one).

public int MyAttr { get; set; }

[DefaultValueAttribute] is not working for this issue i think. Any ideas? Thanks.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET