Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Global objects of Managed types

Is there any way to declare/define global/static objects of managed types ?

like image 936
shadeMe Avatar asked Feb 01 '26 13:02

shadeMe


1 Answers

Although you can have static methods and members in managed code, .NET does not have any concept of a global or completely static object. You can have a class with all static members (and in C#, it can be called a static class, but this is a compiler construct).

However, you can effectively do this via Singletons in C++/CLI. The same issues that exist with Singletons in C# map to C++/CLI when dealing with managed classes.

like image 199
Reed Copsey Avatar answered Feb 04 '26 07:02

Reed Copsey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!