相关疑难解决方法(0)

在C#7中使用Var模式

我在新的C#7中看到了var模式的这个例子

if (o is var x) Console.WriteLine($"it's a var pattern with the type {x?.GetType()?.Name}");
Run Code Online (Sandbox Code Playgroud)

只是使用有什么不同:

var x = o;
Console.WriteLine($"it's a var pattern with the type {x?.GetType()?.Name}");
Run Code Online (Sandbox Code Playgroud)

当这种模式是一个有用的解决方案.

c# pattern-matching

15
推荐指数
1
解决办法
1998
查看次数

标签 统计

c# ×1

pattern-matching ×1