How to retrieve ComboBox selected value as enum type?

后端 未结 4 1786
情书的邮戳
情书的邮戳 2021-01-17 01:30

This is my Enum code:

public enum EmployeeType
{
    Manager,
    Worker
}

I will initialize ComboBox values whil

4条回答
  •  孤城傲影
    2021-01-17 02:13

    You just need to do the reverse, for a given string, what's the correct type.

    EmployeeType result = 
              (EmployeeType)Enum.Parse(typeof(EmployeeType), 
              combobox1.SelectedItem.Content);
    

    P.S. I dont know if combobox1.SelectedItem.Content is correct, I don't do that much WCF.

提交回复
热议问题