samedi 11 juillet 2020

Get all namespaces associated with a Type?

Is there a way to get all the namespaces associated with a class/type using Reflection?

For example, assuming my variable's is:

var list = List<MyClass> 

and my class is defined as

public class MyClass
{
   property int32 MyNumber {get; set;}
}

I would like to be able to get the following namespaces returned:

  • MyCompany.MyClass (as it's being used my MyClass)
  • System.Collections.Generic (as it's being used by List)
  • System as int32 (as it's being used by MyNumber)

Thanks.





Aucun commentaire:

Enregistrer un commentaire