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 ...
Get C# in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.