Mark's Blog About Search Activity

System.ComponentModel.DefaultValueAttribute

I ran into a couple snags today on how to define default values for some properties. Specifically how can I specify the default is Nothing (in this case, for a String type property)?

DefaultValue( CStr(Nothing))

DefaultValue( DirectCast(Nothing, String))

My second problem was how to specify a default for a property with an enumerated type? I tried

DefaultValue( LookupViewType.Standard)

but it still serialized this. The correct syntax is:

DefaultValue( GetType( LookupViewType), "Standard")

If you liked this post, you can share it with your followers or follow me on Twitter!
comments powered by Disqus