Conversion between enumeration types and various types
// Declare the enumerated public enum Sesons {spring, summer, autumn, winter} static void Main (string [] args) {Sesons s = Sesons. spring; string str = "0"; // The enumerated type can be directly converted to int type int s = (int) Sesons. spring int cun = (int) Sesons. spring; // The result is equal to cun = 0
Enumeration type to string type
// Declare the enumerated public enum Sesons {spring, summer, autumn, winter} // declare the enumerated public enum QQstate {OnLine, OffLine, leave, QMe} static void Main (string [] args) {Sesons s = Sesons. spring; QQstate q = QQstate. onLine; string str = "0"; // The enumerated type can be directly converted to int type int s = (int) QQstate. spring // convert the string to Enum. parse, typeof (), get the object type QQstate qzx = (QQstate) Enum. parse (typeof (QQstate), str); Console. writeLine (qzx); Console. readKey ();}