C
C#3y ago
Tvde1

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

I have the following setup:
abstract class Formatter<T> { }
class StringFormatter : Formatter<string> { }
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"
Type type = typeof(StringFormatter);
string typeName = ??? // should be "string"
How do I go about getting this?
4 Replies
Tvde1
Tvde1OP3y ago
Btw there is no reflection tag Maybe Type.GetTypeInheritance() is a good place to start?
Tvde1
Tvde1OP3y ago
Thanks!
Accord
Accord3y ago
✅ This post has been marked as answered!
Want results from more Discord servers?
Add your server