Using ILDasm to reverse engineer some C # code, I found out that the compiler uses the System.Runtime.CompilerServices.RuntimeHelper.InitializeArray method to initialize arrays that contain several constant values โโof primitive types.
It looks like it creates a special structure for each size of the array in bytes and marks it with the [StructLayout] . It is pretty simple. But then there is a field of this type that contains the actual data. How to create such a field in the form of Reflection.Emit and fill it with arbitrary bytes?
source share