Forum Discussion
ahinterl
Feb 11, 2025Brass Contributor
How to find out the type of a generic class?
Exmple: create a new List<string> instance: $a = [System.Collections.Generic.List[string]]::new() With: $a.GetType() I only get: IsPublic IsSerial Name Ba...
- Feb 11, 2025
($a.GetType()).GetType()
Returns:
IsPublic IsSerial Name BaseType -------- -------- ---- -------- False False RuntimeType System.Reflection.TypeInfo
TypeInfo derives from System.Type, which has this method:
$a.GetType().GetGenericArguments()[0]
which returns the same as in my previous post:
IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True String System.Object
ahinterl
Feb 11, 2025Brass Contributor
Found a property that gives me the required information:
$a.GetType().GenericTypeArguments
outputs:
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
That's all I need to know 🙂.
Maybe someone knows of other methods...