mercredi 7 janvier 2015

remove dependency for derived class from base class

I have base class like that



public abstract class BaseEntity
{
public int ID { get; set; }
//other property add here
}


And I have a derive class like that



public class Custormer
{
public string Name { get; set; }
public string Address { get; set; }
//other property add here
}


Now I want to need ID property from base class. To solve this I can use inheritance but it is tight, no need to tight object create


My goal is



var obj = new Custormer();
obj.ID = ""; //need this property. you can use interface, but how?
obj.Name = "";
obj.Address = "";


How can i remove base class dependency from Customer Class. Thank.


Aucun commentaire:

Enregistrer un commentaire