36
1
using System;
2
3
public class Program
4
{
5
public static void Main()
6
{
7
object obj = new Person {
8
FirstName = "Vijay",
9
LastName = "Kumar",
10
Address = new Address {
11
City = "Chennai"
12
}
13
};
14
15
//Property Pattern
16
if(obj is Person { Address: {City: "Chennai" } })
17
Console.WriteLine("Chennai");
18
19
//Extended Property Pattern
20
if(obj is Person { Address.City: "Chennai" })
21
Console.WriteLine("Chennai");
22
}
23
}
24
25
26
public class Address
27
{
28
public string City {get; set;}
29
}
30
public class Person
31
{
32
public string FirstName { get; set; }
33
public string LastName { get; set; }
34
public Address Address { get; set; }
35
}
36
Cached Result