using static System.Console;
object obj = 10;
//before
if (obj is int) {
var i1 = (int)obj;
WriteLine($"i1 = {i1}");
}
//in version 7:
if (obj is int i2) {
WriteLine($"i2 = {i2}");
}
| The is pattern expression extends the familiar is operator to query an object about its type and assign the result in one instruction. |