Answer the question
In order to leave comments, you need to log in
Switch expression how to use it correctly?
I need to use Switch Expression to determine which of the data types (int, byte, sbyte, long, uint) object arg is. I basically figured out how to use it:
when true in bool bl, I return arg + " is byte." etc., if false, nothing should be done, so all checks for different data types will be passed, and in the end I will return that arg is not one of the types listed above, but there is one point that I do not understand .
What do I need to write after false so that nothing is executed?
public static string SwitchExpression(object arg)
{
bool bl = arg is byte;
return bl switch
{
true => arg + " is byte.",
false =>
};
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question