In VB.NET, even with Option Strict
on, it\'s possible to pass an Enum around as an Integer.
In my particular situation, someone\'s using an enum similar to
There isn't a [Enum].TryParse
, but there is [Enum].IsDefined
which if try means your [Enum].Parse
should succeed.
You should also be able to add a None = -1
option to the Enum
In my enums I tend to use a pattern like:
public enum Items
{
Unknown = 0,
One,
Two,
Three,
}
So that a default int -> Enum will return Unknown
Edit - Oh, looks like there is a TryParse in .Net 4. That's neat!