摘要:列舉應用
public enum testType
{
aa= 1,
bb = 2,
cc = 3,
dd = 4,
ee = 5,
}
1.列出所有字串
foreach (string i in Enum.GetNames(typeof(testType)))
{
}
2.字串轉列舉
testType st = (testType)Enum.Parse(typeof(testType), "aa", true);
3.列舉轉數字
(int)st
4.數字轉列舉
(testType)2