I have the following code
Call.Direction CallDir = details.dir;
and the output is either In or out.
my question how can I convert the output to be as follow:
- if CallDir value is In ===> display 0
- if CallDir value is Out ===> display 1
Okay, so if you wanted to return a different value based on the enum, just do this:
return CallDir == Call.Direction.In ? 0 : 1;
However, if what you're saying is details.dir is a string of In or Out and you need to get that into an enum, then do this:
Call.Direction CallDir;
if (!enum.TryParse<Call.Direction>(details.dir, out CallDir))
{
// set it to some default value because it failed
}
Call.Direction; anenum? If so, please show its definition.