Complex Objects

Methods and Objects can be accessed using {...}

Members of a complex object is accessed using ~

Modify The user class.

   public class User
    {
        public Guid Id { get; set; } = Guid.NewGuid();
        public string Name { get; set; }
        public string Email { get; set; }
        public string Phone { get; set; }
        public string Address { get; set; }
        public string Notes { get; set; }
        public User Mother { get; set; }
    }

Form

  private User user;

        public Form1()
        {
            InitializeComponent();

             user = new User()
            {
                Name = "John Doe",
                Email ="doe@email.com",
                Address = "Belvue WA 00100" ,
                Notes="Hello World",
                Phone="+1-800-000-0000",
                Mother = new User()
                {
                    Name = "Mrs Doe",
                    Email = "mrsdoe@email.com",
                    Notes = "I am John's Mother"
                }
            };

            bindingProvider1.Bind(user);
        }

Access the Complex object (Mother).

Output

Member access using ~ is multilevel. You can go deeper to fetch the values

Last updated