[]
        
(Showing Draft Content)

C1.Framework.EnumHelper.IsValid

IsValid Method

IsValid(int, int, int)

Check current value is a valid Enum type

Declaration
public static bool IsValid(int enumValue, int minValueOfEnum, int maxValueOfEnum)
Parameters
Type Name Description
int enumValue

An int indivate the value you want to check

int minValueOfEnum

An int indicate the minimum value of your enum type

int maxValueOfEnum

An int indicate the maximum value of your enum type

Returns
Type Description
bool

A bool indicate the check result, if current value is a valid enum type, return true; otherwise false

Remarks

This method is applicable to check a Sequential defined not-flag-style enum type

IsValid(int, int, int, int)

Check current value is a valid Enum type

Declaration
public static bool IsValid(int enumValue, int minValueOfEnum, int maxValueOfEnum, int maxNumberOfBitsOn)
Parameters
Type Name Description
int enumValue

An int indivate the value you want to check

int minValueOfEnum

An int indicate the minimum value of your enum type

int maxValueOfEnum

An int indicate the maximum value of your enum type

int maxNumberOfBitsOn

An int indicate the max count of bit for test enum value

Returns
Type Description
bool

A bool indicate the check result, if current value is a valid enum type, return true; otherwise false

Remarks

This method is applicable to check a Sequential defined flag-style enum type There is a enum value you want to test is 0x5f, in this enum type, the min value is 0x0f, and max value is 0x100, then this method called below can test its validation:

EnumHelper.IsValid(0x5f, 0x0f, 0x100, 8);

In this scenario, the four parameter is 8, because the max value is 0x100(Binary as 100000000), the max bits on value is 0xff (Binary as 11111111), it's the max number of bits on