Unsafe code and pointers in C#
If you’re concerned about the memory, you could take over from the CLR and the GC and do it all yourself. I wouldn’t recommend this, but sometimes, you have no choice. Although the compiler, the CLR, and the GC do amazing things, they cannot always predict what you are trying to achieve or what your limitations are. Especially for system developers, this can sometimes hinder you in achieving your goals. In those cases, you might have to resort to managing memory yourself. I think an example is in order here.
Let’s start with a simple class:
[MessagePackObject]
public class SimpleClass
{
[Key(0)]
public int X { get; set; }
[Key(1)]
public string Y { get; set; }
} The MessagePackObject and Key attributes come from the MessagePack NuGet library.
The MessagePack library is a tool that enables you to serialize and deserialize instances...