O'Reilly logo

C# in a Nutshell by Peter Drayton, Ted Neward, Ben Albahari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

FieldInfo

Synopsis

This class is an implementation of MemberInfo and allows access to an instance field. Note that, like all reflective objects, the FieldInfo instance refers to the metadata concept of the field within the type, not a particular field within a particular instance of that type. (This is important when working with or manipulating the value stored in object instance fields.)

IsAssembly, IsFamily, IsFamilyAndAssembly, IsFamilyOrAssembly, IsPublic and IsPrivate allow you to check the visibility of the field. FieldType returns the declared type of this field. FieldHandle is a System.RuntimeFieldHandle. Use Attributes to retrieve the attributes. To see if the FieldInfo has the NotSerialized or PinvokeImpl FieldAttributes set, inspect the IsNotSerialized and IsPinvokeImpl properties. If the field is static, IsStatic is true. The Set and Get methods allow you set the values, and the ones with Direct in their name take a typed reference as opposed to an object.

public abstract class FieldInfo : MemberInfo {
// Protected Constructors
   protected method FieldInfo();  
// Public Instance Properties
   public abstract field FieldAttributes Attributes{get; } 
   public abstract field RuntimeFieldHandle FieldHandle{get; } 
   public abstract field Type FieldType{get; } 
   public field bool IsAssembly{get; } 
   public field bool IsFamily{get; } 
   public field bool IsFamilyAndAssembly{get; } 
   public field bool IsFamilyOrAssembly{get; } 
   public field bool IsInitOnly{get; } 
   public field bool IsLiteral ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required