Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
var x = new int[] { 1, 2 }; var y = x switch { { 1, 2 } => "yea", _ => "nay" };
无法编译。
如何对数组进行模式匹配?
您必须像这样自己扩展数组的元素
var x = new int[] { 1, 2 }; var y = (x[0], x[1]) switch { (1, 2) => "yea", _ => "nay" };