dimanche 30 octobre 2016

What is the best practice for setting/determining the concrete types in a List

If I have either:

List or List

Where many types implement the interface iCanSpeak or use the abstract class Animal as a base class.

What is the best practice for determining/setting the concrete types that are in my actual list?

I know C# offers .TypeOf and I have seen examples that use an enumeration in the base class or interface to make determining easier, but what is the best practice and why?

Potentially off-topic follow-ups:

Also, what is TypeOf doing under the hood? Is it up casting? Why aren't the properties of the different concrete classes lost when put into a list?

Does... List == List

If the defined methods and properties are the same?

Aucun commentaire:

Enregistrer un commentaire