© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
6 replies
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?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ base class/abstract for record
C#CC# / help
3y ago
Mocking derived class with abstract base class
C#CC# / help
4y ago