© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
24 replies
docklandslightrailway

❔ Is there any way to create a pointer to a C# generic class

I have a script that uses a class "fogGrid<bool>". At the start of the script I want it to be able to specify which instance of the class is manipulated.
Essentially I want fogGrid to be a pointer to instances of the same class in another script (SqrFog, TriFog or CirFog)

I've allowed unsafe code to run, but whenever I try to run it, it states that "It cannot take the address of, get the size of, or declare a pointer to a managed type ("FogSystem<bool>")

For tests sake i was just trying to get it to point to sqrFog. After some googling it says I cannot make pointers to generic types, is there any workaround?
image.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,828Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Nested classes in C# with parent being a generic class
C#CC# / help
13mo ago
❔ giving current class type to a generic class
C#CC# / help
3y ago
without generic class can i create generic method or generic field?
C#CC# / help
4y ago
Is there a way to unload a class from the ram?
C#CC# / help
5mo ago