My watch window says:
- sizeof(char) = 2
- sizeof(CharTest) = 4
EDIT-----------------------
Just replicated it by using:
System.Runtime.InteropServices.Marshal.SizeOf ( new CharTest() )
EDIT 2---------------------
InteropServices.Marshal.SizeOf is affected by the CharSet that applies to the struct. By default, C# applies ANSI multple-byte CharSet to types. ANSI multiple-byte will use one or two bytes to store character, and on a new instance of the struct the char variables are initialized to their default value which is "\0" or null, thereby only using one byte.
Because of the default CharSet for C#, this struct does not have a predefined size and the sizeof() can only be used in unsafe block where it apparently calculates the max potential of the struct, whereas Marshal.SizeOf is applied to an instance of the struct and is measuring actual size in use.