Inheritance or identifier
- by Lina
Hi!
Does anyone here have opinions about when to user inheritance and when to use an identifier instead?
Inheritance example:
class Animal
{
public int Name { get; set; }
}
class Dog : Animal {}
class Cat : Animal {}
Identifier example:
class Animal
{
public int Name { get; set; }
public AnimalType { get; set; }
}
In what situations should i prefer which solution and what are the pros and cons for them?
/Lina