官术网_书友最值得收藏!

Var pattern

The var pattern checks if the var is equal to some type. The following example shows how the var pattern can be used to check for the type and print the Type name:

if (person is var Person) Console.WriteLine($"It is a person object and type is {person.GetType()}"); 
To learn more about patterns, you can refer to the following link: https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-7#pattern-matching.
主站蜘蛛池模板: 华阴市| 富民县| 惠水县| 瑞昌市| 阿城市| 永寿县| 万宁市| 会宁县| 崇左市| 平湖市| 周至县| 黄石市| 咸宁市| 同江市| 临桂县| 瑞安市| 壤塘县| 大庆市| 开江县| 通榆县| 延长县| 伊吾县| 措美县| 深水埗区| 上林县| 图木舒克市| 射阳县| 青川县| 乐山市| 富顺县| 阆中市| 娄底市| 望谟县| 威远县| 英山县| 新巴尔虎右旗| 桃江县| 恭城| 出国| 甘德县| 庄浪县|