Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the order of returned Types by Assembly.GetTypes()?

If I get the list of types in my AppDomain, is there an inherent ordering to these types?

List<Type> myTypes = new List<Type>();
foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
    myTypes.AddRange(a.GetTypes());

This seems to produce a list that's grouped by types in a namespace, but I can't see a pattern to the namespace groups themselves (or the types within each namespace group).

like image 659
Michael Avatar asked Aug 09 '11 18:08

Michael


1 Answers

Even if you can discern an order, there's nothing in the documentation to guarantee it - so you absolutely should not rely on it.

If you want a particular ordering, you should ensure it yourself.

like image 161
Jon Skeet Avatar answered Sep 19 '22 17:09

Jon Skeet