I have a class property of type enum. The enum name is TemplateType:
Private _Type As TemplateType
< _
Bindable(True), _
DefaultValue(""), _
> _
Public Property Type() As TemplateType
Get
Return _Type
End Get
Set(ByVal value As TemplateType)
_Type = value
End Set
End Property
I need to run some code if a Type was defined. If Type wasn't defined then I will not run this code.
How can I do this?
Should I add a Enum item named None and make it the default value?
shapper
Contributor
3932 Points
3789 Posts
Enum
Mar 17, 2008 12:46 PM|LINK
Hello,
I have a class property of type enum. The enum name is TemplateType:
Private _Type As TemplateType < _ Bindable(True), _ DefaultValue(""), _ > _ Public Property Type() As TemplateType Get Return _Type End Get Set(ByVal value As TemplateType) _Type = value End Set End PropertyI need to run some code if a Type was defined. If Type wasn't defined then I will not run this code.
How can I do this?
Should I add a Enum item named None and make it the default value?
Thanks,
Miguel
DavidKiff
Star
8660 Points
1733 Posts
Re: Enum
Mar 17, 2008 01:24 PM|LINK
Yeah personally I would add an "Unknown" or "None" value into the enum. Another approach is to use:
Nullable<TemplateType> then it can contain null?!
Visit my site
Follow me on Twitter
SilverStyle
Member
90 Points
20 Posts
Re: Enum
Mar 19, 2008 03:39 PM|LINK
Personally, I also think, that it's a good strategy to provide a "None" ur "Undefined" item in an enumeration, providing it with the index 0.
Then you can easily query the variable of type YourEnumeration if it's greater than 0.