1. 程式人生 > >字串轉列舉

字串轉列舉

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
}