samedi 30 janvier 2016

How to access declaring type for static member in C#

I have a scenario in which i need to access declaring type of an static property.the scenario is as following :

public static class FOO{
     public static SomeType Bar{get;set;}
}

public static class BAZ{
   public static void SomeMethod(SomeType p){
       //here i wanna get type of container of 'p' which should be FOO
   }
}    

 BAZ.SomeMethod(FOO.Bar);

but when i call p.GetType().DeclaringType i get null value, any suggestions?





Aucun commentaire:

Enregistrer un commentaire