Enumerated types are often used in projects, and different types need to be used in different places, such as: quick conversion between Enum, int, and string.
public enum Color { Red=1, Green=2 }
(1) Enum converted to String
Color.Read.ToString()
Convert.ToString(Color.Green)
(2) Enum converted to int
Convert.ToInt32(Color.Green)
(A) Conversion of String to Enum
(Color)Enum.Parse(typeof(Color), "Red");
(B) Convert Int to Num
(Color)1
Source: https://www.cnblogs.com/mqingqing123/p/8456242.html
public enum Color { Red=1, Green=2 }
(1) Enum converted to String
Color.Read.ToString()
Convert.ToString(Color.Green)
(2) Enum converted to int
Convert.ToInt32(Color.Green)
(A) Conversion of String to Enum
(Color)Enum.Parse(typeof(Color), "Red");
(B) Convert Int to Num
(Color)1