Inheritance or identifier
Posted
by Lina
on Stack Overflow
See other posts from Stack Overflow
or by Lina
Published on 2010-03-16T09:41:49Z
Indexed on
2010/03/16
9:46 UTC
Read the original article
Hit count: 269
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
© Stack Overflow or respective owner