I've tried to implemented c# 8.0 switch-case but it's not working unfortunatelly, I want to if case is satisfied to return a specific string for that satisfied case in switch expression.
Here's my code:
public static void GetErrMsg(Exception ex) =>
ex switch
{
ex is UserNotFoundException => "User is not found.",
ex is NotAuthorizedException => "You'r not authorized."
};
But I gt a following message:
Error CS0201 Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement.
Error CS0029 Cannot implicitly convert type 'bool' to 'System.Exception'