How do I define a list of properties
I hav开发者_StackOverflow中文版e a class called "heater". One of the properties is "designstatus", a string. I want to limit the property to one of three choices; "current", "obsolete", "notdesigned". How would I do this?
You can use an Enum
. E.g.:
Public Enum DesignStatus
Current
Obsolete
NotDesigned
End Enum
You can do this using an Enum, but as an Enum is an Integer this isn't going to completely do what you want, so I would suggest doing something similar to this:
Public Enum DesignStatuses
Current
Obsolete
NotDesigned
End Enum
So when you need to get the actual String name of the Enum that you have used you can do:
DesignStatus.ToString("G")
Which will return the actual name of the constant instead of the value.
精彩评论