“StructLayout” (Problem)
What will the following code display?
1
public struct Foo
2
{
3
public byte Byte1;
4
public int Int1;
5
}
6
public struct Bar
7
{
8
public byte Byte1;
9
public byte Byte2;
10
public byte Byte3;
11
public byte Byte4;
12
public int Int1;
13
}
14
void Main()
15
{
16
Console.WriteLine(Marshal.SizeOf(typeof(Foo)));
17
Console.WriteLine(Marshal.SizeOf(typeof(Bar)));
18
}
Copied!
Solution
Copy link