C# Class EnumExtensions, code

Show file Open project: shendongnian/code Class Usage Examples

Public Methods

Method Description
From ( value ) : TEnum

Converts a into a through pointer cast. Does not throw if the sizes don't match, clips to smallest data-type instead. So if is smaller than bits that cannot be captured within 's size will be clipped.

FromName ( string desc ) : T

Find the enum from the description attribute.

GetAttribute ( Enum value ) : T
GetDescription ( value ) : string
GetDescriptions ( ) : string>.IDictionary
To ( value ) : TResult

Converts a into a through pointer cast. Does not throw if the sizes don't match, clips to smallest data-type instead. So if is smaller than bits that cannot be captured within 's size will be clipped.

ToName ( Enum value ) : string

Method Details

From() public static method

Converts a into a through pointer cast. Does not throw if the sizes don't match, clips to smallest data-type instead. So if is smaller than bits that cannot be captured within 's size will be clipped.
public static From ( value ) : TEnum
return TEnum

FromName() public static method

Find the enum from the description attribute.
public static FromName ( string desc ) : T
desc string
return T

GetAttribute() public static method

public static GetAttribute ( Enum value ) : T
value Enum
return T

GetDescription() public static method

public static GetDescription ( value ) : string
return string

GetDescriptions() public static method

public static GetDescriptions ( ) : string>.IDictionary
return string>.IDictionary

To() public static method

Converts a into a through pointer cast. Does not throw if the sizes don't match, clips to smallest data-type instead. So if is smaller than bits that cannot be captured within 's size will be clipped.
public static To ( value ) : TResult
return TResult

ToName() public static method

public static ToName ( Enum value ) : string
value Enum
return string