编程语言
首页 > 编程语言> > C# 字符串转枚举

C# 字符串转枚举

作者:互联网

private void btnStart_Click(object sender, EventArgs e)
{
string testText = "Sunday";
Days2 d = (Days2)Enum.Parse(typeof(Days2), testText);
MessageBox.Show(d.ToString());
}

enum Days2
{
Sunday,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday
}

标签:C#,Friday,Days2,Sunday,Thursday,枚举,private,字符串,testText
来源: https://www.cnblogs.com/ProjectDeveloping/p/10759562.html