vendredi 17 juillet 2015

C# Sorting Type hierarchy

I have multiple Types stored in a list, and I need to have them sorted from the most concrete type to the most general ones, example:

Vehicle
  Car
  Bike

Person
  Manager
  Programmer

So it makes list with: Vehicle, Car, Bike, Person, Manager, Programmer types. Now I need to get ordered list where more concrete type is always before more general type like: Car, Bike, Vehicle, Manager, Programmer, Person. Is there some simple/elegant way to achieve this, besides some gymnastics with Type.IsAssignableFrom ?





Aucun commentaire:

Enregistrer un commentaire