C# 7 Pattern Match with a tuple
问题 Is it possible to use tuples with pattern matching in switch statements using c# 7 like so: switch (parameter) { case ((object, object)) tObj when tObj.Item1 == "ABC": break; } I get an error that says tObj does not exist in the current context . I have tried this as well: switch (parameter) { case (object, object) tObj when tObj.Item1 == "ABC": break; } This works fine: switch (parameter) { case MachineModel model when model.Id == "123": break; } 回答1: Remember that C#7 tuples are just