Skip to Main Content
C# in a Nutshell, Second Edition
book

C# in a Nutshell, Second Edition

by Peter Drayton, Ben Albahari, Ted Neward
August 2003
Intermediate to advanced content levelIntermediate to advanced
928 pages
32h 1m
English
O'Reilly Media, Inc.
Content preview from C# in a Nutshell, Second Edition

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 PinvokeImplFieldAttributes 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 FieldInfo( );
// Public Instance Properties
   public abstract FieldAttributes Attributes{get; }
   public abstract RuntimeFieldHandle FieldHandle{get; }
   public abstract Type FieldType{get; }
   public bool IsAssembly{get; }
   public bool IsFamily{get; }
   public bool IsFamilyAndAssembly{get; }
   public bool IsFamilyOrAssembly{get; }
   public bool IsInitOnly{get; }
   public bool IsLiteral{get; }
   public bool IsNotSerialized{get; }
   public bool IsPinvokeImpl ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# in a Nutshell

C# in a Nutshell

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

C# 7.0 in a Nutshell

Joseph Albahari, Ben Albahari
C# Cookbook, 2nd Edition

C# Cookbook, 2nd Edition

Jay Hilyard, Stephen Teilhet
C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard

Publisher Resources

ISBN: 0596005261Catalog PageErrata