.NET DefaultValue attribute

Posted by Aaron on Stack Overflow See other posts from Stack Overflow or by Aaron
Published on 2010-02-24T21:52:31Z Indexed on 2010/05/26 17:31 UTC
Read the original article Hit count: 220

Filed under:
|
|
|

I've heard people say a few different things about the DefaultValue attribute including:

  • "It sets the value of the property before anything else uses it."
  • "It doesn't work for autoproperties."
  • "It's only for decoration. You must manually set actual default values."

Which (if any) is right? Does DefaultValue actually set default values? Are there cases where it doesn't work? Is it best just not to use it?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .net-3.5