var str = "abcDEF"; switch (str) { case string x when x.StartsWith("abc"): Console.WriteLine("abc"); break; case string x when x.StartsWith("efc"): Console.WriteLine("efc"); break; } Console.Read(); }