Answer the question
In order to leave comments, you need to log in
How can you assign an ordinary string to an enum variable?
i need something like this
Programm m_CurentProgramm;//перечисление enum
string set = comboBox1.SelectedText; // например Sity
m_CurentProgramm = Programm.set; // мне нужно собрать значение Programm.Sity
Answer the question
In order to leave comments, you need to log in
enum SomeEnum {
A,
B
}
var text = "B";
var enumValue = Enum.Parse<SomeEnum>(text); // SomeEnum.B
var enumValue = (SomeEnum) Enum.Parse(typeof(SomeEnum), text);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question