Collapse the table of content
Expand the table of content
Expand Minimize

OpCodes.Ldflda Field


Finds the address of a field in the object whose reference is currently on the evaluation stack.

Namespace:   System.Reflection.Emit
Assembly:  mscorlib (in mscorlib.dll)

public static readonly OpCode Ldflda

The following table lists the instruction's hexadecimal and Microsoft Intermediate Language (MSIL) assembly format, along with a brief reference summary:


Assembly Format


7C < T >

ldflda field

Pushes the address of field in a specified object onto the stack.

The stack transitional behavior, in sequential order, is:

  1. An object reference (or pointer) is pushed onto the stack.

  2. The object reference (or pointer) is popped from the stack; the address of the specified field in the object is found.

  3. The address of the specified field is pushed onto the stack.

The ldflda instruction pushes the address of a field located in an object onto the stack. The object must be on the stack as an object reference (type O), a managed pointer (type &), an unmanaged pointer (type native int), a transient pointer (type *), or an instance of a value type. The use of an unmanaged pointer is not permitted in verifiable code. The object's field is specified by a metadata token that must refer to a field member.

The value returned by ldflda is a managed pointer (type &) unless the object is pushed onto the stack as an unmanaged pointer, in which case the return address is also an unmanaged pointer (type native int).

The ldflda instruction can be preceded by either or both of the Unaligned and Volatile prefixes.

InvalidOperationException is thrown if the object is not within the application domain from which it is being accessed. The address of a field that is not inside the accessing application domain cannot be loaded.

NullReferenceException is thrown if the object is null and the field is not static.

MissingFieldException is thrown if the specified field is not found in the metadata. This is typically checked when Microsoft Intermediate Language (MSIL) instructions are converted to native code, not at run time.

The following Emit method overload can use the ldflda opcode:

  • ILGenerator.Emit(OpCode, FieldInfo)

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.1
Windows Phone
Available since 8.1
Return to top
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft