Field offsets can help you in numerous ways, first what comes in mind is that you can set fields of the struct or class instance without using TypedReference (doesn’t work in IL2CPP) and without GC allocs which comes with boxing when either instance or a value is a struct. Second, it could help you with unmanaged access to the class/struct for custom binary serialization, etc.
Tag: IL
Saddling up IL to our benefit
When you come from C++ to C# it’s such a relief. C# is a greatly designed language, you can do almost anything you want with it, apart from some design choises like macroses and C++ template<>. But sometimes we can find ourselves near the wall which you can’t pass with C# itself. IL Comes To […]
C# Bool To Int Conversion
Overview and performance comparasion for bool -> int/uint/byte conversion in C#
And simple solution for fast platform-independent conversion.