P
Patrick B
Is there a way to check if a certain variable is an enum?
Example code:
public enum MyEnum {
Monday,
Tuesday,
Wednesday
}
public void MyMethod()
{
MyEnum myEnum = MyEnum.Monday;
string myString = "Bla bla bla";
bool firstTry = IsEnum(myEnum);
bool secondTry = IsEnum(myString);
}
Is there a way to write a function IsEnum() so that firstTry is true and
secondTry is false?
myEnum.GetType() tells me that myEnum is of the type MyEnum.
GetTypeCode() tells me that it's an Int32.
Thanks,
-Patrick
Example code:
public enum MyEnum {
Monday,
Tuesday,
Wednesday
}
public void MyMethod()
{
MyEnum myEnum = MyEnum.Monday;
string myString = "Bla bla bla";
bool firstTry = IsEnum(myEnum);
bool secondTry = IsEnum(myString);
}
Is there a way to write a function IsEnum() so that firstTry is true and
secondTry is false?
myEnum.GetType() tells me that myEnum is of the type MyEnum.
GetTypeCode() tells me that it's an Int32.
Thanks,
-Patrick