Switch expression

  • Thread starter Thread starter EuroEager
  • Start date Start date
E

EuroEager

Guest
Is it possible to write something similar (but working) to:

public object GetSomething(string text) =>
text.Substring(0, 1) switch
{
"A" => new object(),
_ => { Console.WriteLine("text is null or not A"); null}
};

? (how?)

Continue reading...
 
Back
Top