Skip to content

Instantly share code, notes, and snippets.

@donma
Created October 28, 2025 05:29
Show Gist options
  • Select an option

  • Save donma/4f99be05feaedb112f54c440aff1e1c1 to your computer and use it in GitHub Desktop.

Select an option

Save donma/4f99be05feaedb112f54c440aff1e1c1 to your computer and use it in GitHub Desktop.
var userType = "";
var result = userType switch
{
var t when string.IsNullOrEmpty(t) =>
new Func<string>(() => { Console.WriteLine("Default"); return "CALL_DEFAULT"; })(),
"PLUS" =>
new Func<string>(() => { Console.WriteLine("Plus"); return "CALL_PLUS"; })(),
"PREMIUM" =>
new Func<string>(() => { Console.WriteLine("Premium"); return "CALL_PREMIUM"; })(),
"Ultimate" =>
new Func<string>(() => { Console.WriteLine("Ultimate"); return "CALL_ULTIMATE"; })(),
_ =>
new Func<string>(() => { Console.WriteLine("Default"); return "CALL_DEFAULT"; })(),
};
Console.WriteLine(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment