Using GetHashCode for getting Enum int value
I have an enum public enum INFLOW_SEARCH_ON { ON_ENTITY_HANDLE = 0, ON_LABEL = 1, ON_NODE_HANDLE = 2 } // enum INFLOW_SEARCH_ON I have to use this enum for searching in a grid column. To get the column index I am using MyEnumVariable.GetHashCode() Which works ok, or should I use (short)MyEnumVariable I am a bit confused over using GetHashCode() . Is there any problem using that? Using GetHashCode() is incorrect. You should cast to int . Using it the way you do is asking for raptors(or Raymond) to come and eat you. That GetHashCode() happens to return the integer value of the enum is an