Posts

Showing posts with the label Generic Class

C# how to get type of generic class using reflection

In the following example, given an instance of SystemFolder, how would you find the generic type Folder given that SystemFolder  :  IDropTarget < Folder >? using  System; using  System.Collections.ObjectModel; using  System.Diagnostics; using  System.Linq; namespace  CSharpGenerics { public   class   GenericUtilities     {          // Example Type type = GenericUtilities.GetGenericType(new SystemFolder()); will return Folder          public   static   Type  GetGenericType( object  @object)         {              var  type = @object.GetType();              var  iDropTargetObject =...