© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
8 replies
Mmd4j

❔ giving current class type to a generic class

Hello the description seems to be not long as i need to write the whole thing so i'll describe the whole thing here.
I have a class called Spell which is a generic class and only accepts a class with type of Legend. but now i have another class which is called TestLegend and is based on Legend. i also do have another class which is TestSpell and it generic type is TestLegend.
So now i want to create a Spell array which can have any kind of Legend in itself. but heres the thing that i have to enter a type of Legend before creating an array due to the Spells' generic type and if i enter Spell<Legend>[] i cannot enter TestSpell because the array must only contain Spell with generic type of <Legend> what should i do?
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

❔ Check What Generic Type a Class Implements
C#CC# / help
4y ago
❔ generic class in generic method
C#CC# / help
3y ago
Design Pattern for mapping generic class type to implementation
C#CC# / help
3y ago
Generic Class Help
C#CC# / help
3y ago