[Mono-list] Re: Embedded Mono queries

Miguel de Icaza miguel@ximian.com
06 Mar 2002 14:23:29 -0500

> Many thanks. I hadn't come across the StructLayout attribute before. Will
> this information be used by the compiler to generate the offsets in the
> IL code, or is it passed on to the runtime to sort out? The "C# Essentials"
> book says "..the difference is a C# program finds this offset by looking it
> up using the field name; C field names are compiled directly into offsets"

The compiler flags the structure to have the LayoutExplicit, and then
records the offset of each field.  The compiler still generates the same
instructions to load fields (ldfld <token>).  The runtime is the one
that does the final translation to actual offsets.