Rachael Dawn
Rachael Dawn

Reputation: 889

How do I make a whole C# application "unsafe"?

So, I love the C# language, and the automatic getters, setters, and so on, but I want to utilize it to be able to do a good portion of the plumbing myself. A great deal of the syntax is specifically why I want to use C# as opposed to sucking it up and picking C++ back up (which isn't entirely out of the question here).

My objective is to use SDL, GDI+, DirectX, or something of that nature to be able to create all of my own Windows from scratch like this, but using C#. I am very okay with using P\Invoke, doing my own memory management, and so on.

So, is there a way to mark an entire application as unsafe so I can do my own memory management?

Upvotes: 2

Views: 178

Answers (1)

Sefe
Sefe

Reputation: 14017

You can't do your own memory management. You can use an open source framework like Mono and write your own garbage collector. But it's unlikely you'll reinvent a better wheel.

And unsafe doesn't mean you can override default memory management. It means that pointer operations are allowed. You are still in managed memory and you have no control over creation or destruction of your objects.

Upvotes: 2

Related Questions