Вакансии
Developer java
Intesting
Город: | Харьков |
З/п: | обсуждается с кандидатом |
Опыт работы: | Нет опыта |
Отзывы о компании Intesting |
Sometimes you have a string value that you want to convert to an equivalent enum.
This could happen when you are accepting user input and want to put the input into your objects.
The language provides a good way to convert strings to enums.
You will use the Enum static class and the Parse method on itEnum.ПасеTypeof Operator Enum.
ParseThe tricky part of using this method involves typeof and casting.Get names.
It is possible to get the name for any value of a specified enum.
You can also get all the string representations of the enum values at once: this is done with the GetNames method.
This can streamline some code that must print out enums. Enum.GetName
|
0 | Tweet | Нравится |
|