If I create an enum like this
public enum ImportType
{
Direct,
Indirect,
InBond
}
and I have a method that takes an ImportType as parameter as follows
public bool ProcessValidImport(ImportType type)
{
// Process ImportType variable here
}
I can go and call the method as follows
bool blnProcessed = ProcessValidImport((ImportType)7);
But the ImportType
variable value of 7
passed in to the method is not valid at all because any integer will work if cast. The enum defaults to an int type, so what is the best way to validate that an enum in this case is in fact a valid ImportType
.