c# - Accessing Properties of Base class from derived class using Generic List -
in c#, best way access property of base class when generic list contains derived class.
public baseclass1 { public property a{get;set;} public property b{get;set;} } public baseclass2:baseclass1 { public property c{get;set;} public property d{get;set;} } public classa:baseclass2 { } public class implement { list<classa> list1 = new list<classa>() console.writeline("would add person");//if yes add person list dynamically { //is possible acesses properties of baseclass using derived class list list1.property = console.readline();//read input console list1.property b = console.readline();//read input console . . list.property d = console.readline();//read input console list1.add(property a,property b);//add properties of baseclass1 , baseclass2 derived class } }
i want take values of base class properties console , add values list , increase list if user wants add more objects of classa. possible??
list1.add( new classa { = a, b = b, c = c } );
Comments
Post a Comment