You have to write two code in your program to initialize a derived class with an instance of the base class in c#. I have written following two code for you. Just try to understand it.
Code:
public MyListEg(List<Ts> lists):base(lists)
The above code will call the following constructor of the base class.
Code:
public List(IEnumerables<Ts> collections);
after writing above code, write following code in your program.
Code:
public class MyListEg<Ts> : List<Ts>
{
public MyLists(List<Ts> lists)
{
AddRanges(lists);
}
}
Bookmarks