Is it possible to determine via reflection whether a field is of generic type or not?
If it is possible, how can it be done?
I suppose my question was not clear enough so I am editing it now.
EDIT:
If a would have a type defined as in following example and DID NOT have instance of Holder<T> type, but only System.Type instance retrieved via System.Reflection.Assembly.GetTypes and System.Reflection.FieldInfo instance describing field _instance, how can I determine whether _instance field is of generic type
public class Holder<T>
{
private T _instance;
}
Using the FieldInfo for the field, you can check the IsGenericType property of the FieldType property if you want to know if the field is a generic type in itself.
If you what to check if the field is of the type of the generic in a generic class definition, then you’ll want to check IsGenericParameter instead.
You can, of course, combine these. Checking if the field is a generic of the type in a generically defined class, is more problematic, but still can be done. You simply have to check the type parameters of the generic type to see if one of them has IsGenericParameter set. Note the following example is only one level deep; if you want something comprehensive you’ll want to define a method and use it recursively.