I’ve been looking around for this for awhile. I would like to know how to get the type of the template passed into creating a list. For example.
List<string> listOfStrings = new List<string>();
How would I get the string type from this? I know how to use the type to get the fields and find the list type but not the template within it.
In this instance, you can get it like this
Note that if you try this on a non generic type, it will fail because the length of the GetGenericArguments array will be 0, but you can of course take measures to control the length of the array.