ยฉ 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#โ€ข2y agoโ€ข
14 replies
IsNotNull

More Elegant Way to Make a Generic Lookup Type

I want to store things for lookup by a generic type.
Case: I have a storage class that I want to expose a Get<T>(string key) method, and internally is uses specialized storage lookup instances for each type.

Is the only way to do that today to use a Dictionary<System.Type, AbstractThing> and then cast my AbstractThing to MoreSpecific<T>?
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

โœ… [ASPNETCORE - HealthCheck - Timeout] Trying to find a more elegant way to write this
C#CC# / help
3y ago
Using pointers as generic a generic type
C#CC# / help
4y ago
โ” Is there a way to make this more cleaner?
C#CC# / help
3y ago
Is there a good way to use a object from Type Type in a generic method?
C#CC# / help
4y ago