-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ToEnumOrDefault #61
Comments
Hi |
@kurnakovv Hey, why do we sometimes use TAnotherEnum and sometimes TEnum, what's the difference, why do we need two? |
@Kurnakova it depends on an input parameter I hope it's clear P.S. Of course you can use |
Why does say that it returns TAnotherEnum though? Or is this a typo? |
Good catch, fixed |
Why is it bool? Shouldn't it be "MyEnum" or smth like that, since this method returns enums? |
@Kurnakova yep, good catch, thank you! I fixed |
ToEnumOrDefault
Description
Try convert string value to enum or return default value if not possible.
Signature
bool ToEnumOrDefault(this string, bool [default = true], TEnum [default = TEnum]) where TEnum : struct, Enum
Type Parameters
TEnum
- Enum that we want try to get after convert.Parameters
string stringValue
- Input string we want to convert toTEnum
.bool ignoreCase
- Ignore or regard case.TEnum defaultValue
-TEnum
or default ofTEnum
.Returns
TEnum
ordefaultValue
if not possible to convert.Code examples
The text was updated successfully, but these errors were encountered: