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.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.238.171