What error are you getting? I assume you just coded your method incorrectly and it's throwing an error saying you can't convert from enum to int? Your method signature should look like this:
I also wouldn't recommend casting your enums to and from their values for internal code, for example this is bad:Code:void SetContainerType(class1.ContainterTypes container) { if(container == class1.ContainerTypes.CT_XML) ConvertToXml(); }
Code:// This is bad switch((int) myEnum) { case 0: break; case 1: break; case 2: break; } // This is good switch(myEnum) { case MyEnum.Red: break; case MyEnum.Blue: break; case MyEnum.Green: break; }




Reply With Quote