Krishna Ramisetty

Krishna Ramisetty

  • NA
  • 18
  • 3.3k

How to call child class property in Parent class

Aug 3 2021 11:47 AM

Hello Everyone,

I have below classes. I want to to initialize child class property(List<int> ChildList) in parent class. please help me how to do this.

  public class Child : Parent
    {
        public Child (Data param) : base(param)
        {
        }
        public List<int> ChildList { get; set; }
    }
 
    public class Parent
    {     
        public Parent(Data param)
        {
            this.MsgInfo = param;
        }
     
        public Data MsgInfo { get; set; }
    }

public class Data 
    {
public int Type { get; set; }
public long ID   {  get; set; }
}

I am trying to initialize like this. but not showing ChildList property here. what's wrong here

p.MsgInfo.ChildList

 

Thanks

Krish


Answers (1)