Edit: everything bellow applies to Mono/Xamarin, but crashes on .NET with TypeLoadException
When field2 is printed to the stdout I get a new integer each time I run the program. What is the meaning of this value?
class Program
{
[StructLayout(LayoutKind.Explicit)]
struct Data
{
[FieldOffset(0)]
public object Field1;
[FieldOffset(0)]
public int Field2;
}
public static void Main()
{
var a = new Data();
a.Field1 = new object();
Console.WriteLine(a.Field2);
}
}