I am trying to use a type pattern in C# 7 against a tuple type:
var lst = new List<object>();
lst.Add("foo");
lst.Add(("bar","baz"));
foreach (var item in lst) {
switch (item) {
case string s:
break;
case (string, string) t: //Compiler error here
break;
}
}
but the compiler gives me the following error:
Invalid expression term 'string' A constant value is expected
How can I resolve this?
N.B. I know I can use:
case ValueTuple<string,string> t:
but I am wondering if there is a better syntax.