Hi guys,
i was working with Enum and one Question strike, i thought it would be
good idea to ask more experience guys around.
the scenerio is like this :
[System.ComponentModel.DefaultValue(check.None)]
public enum check
{
No,
None,
yes,
why
}
check ch;
all i want to know is, is it possible to assign default value
(like .net value type has NULL as default value) this way?
and if not this way and u know another way of doing it plz let me
know.
by another way i dont mean like this
check ch=check.None;
i mean it should be like the way i declared on the top.
i would appriciate all your opinon on this.
thanks,
Lucky
Marc Gravell - 14 Mar 2007 17:05 GMT
Use explicit values to get default(T) behaviour, with the 0 item being
the default.
However, defaults (in [DefaultValue] terms) apply to individual
properties, not type-defs - so you can still specify a default of
"yes", "No" or whatever for each property.
Marc
Herfried K. Wagner [MVP] - 14 Mar 2007 23:15 GMT
"Marc Gravell" <marc.gravell@gmail.com> schrieb:
> Use explicit values to get default(T) behaviour, with the 0 item being
> the default.
... or 'Nothing' in VB.

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>