Use reflection to get type of abstract base class [Answered]

TTvde19/19/2022
I have the following setup:
abstract class Formatter<T> { }
class StringFormatter : Formatter<string> { }

I want to use reflection to find out what kind of formatter a certain type is
Type type = typeof(StringFormatter);
string typeName = ??? // should be "string"

How do I go about getting this?
TTvde19/19/2022
Btw there is no reflection tag
TTvde19/19/2022
Maybe Type.GetTypeInheritance() is a good place to start?
OOryp4ik9/19/2022
get base type, get its generic type args
TTvde19/19/2022
Thanks!
AAccord9/19/2022
✅ This post has been marked as answered!