다음을 통해 공유


BindingFlags Enumeration

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Specifies flags that control binding and the way in which the search for members and types is conducted by reflection.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

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

Syntax

'Declaration
<ComVisibleAttribute(True)> _
<FlagsAttribute> _
Public Enumeration BindingFlags
[ComVisibleAttribute(true)]
[FlagsAttribute]
public enum BindingFlags

Members

Member name Description
Supported by Silverlight for Windows PhoneSupported by Xbox 360 Default No binding flag.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 IgnoreCase The case of the member name should not be considered when binding.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 DeclaredOnly Only members declared at the level of the supplied type's hierarchy should be considered. Inherited members are not considered.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 Instance Instance members should be included in the search.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 Static Static members should be included in the search.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 Public Public members should be included in the search.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 NonPublic Non-public members should be included in the search.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 FlattenHierarchy Public and protected static members up the hierarchy should be returned. Private static members in inherited classes are not returned. Static members include fields, methods, events, and properties. Nested types are not returned.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 InvokeMethod A method is to be invoked. This must not be a constructor or a type initializer.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 CreateInstance Reflection should create an instance of the specified type. This flag calls the constructor that matches the given arguments. The supplied member name is ignored. If the type of lookup is not specified, (Instance | Public) will apply. It is not possible to call a type initializer.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 GetField The value of the specified field should be returned.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 SetField The value of the specified field should be set.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 GetProperty The value of the specified property should be returned.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 SetProperty The value of the specified property should be set. For COM properties, specifying this binding flag is equivalent to specifying PutDispProperty and PutRefDispProperty.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 PutDispProperty The PROPPUT member on a COM object should be invoked. PROPPUT specifies a property-setting function that uses a value. Use PutDispProperty if a property has both PROPPUT and PROPPUTREF and you need to distinguish which one is called.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 PutRefDispProperty The PROPPUTREF member on a COM object should be invoked. PROPPUTREF specifies a property-setting function that uses a reference instead of a value. Use PutRefDispProperty if a property has both PROPPUT and PROPPUTREF and you need to distinguish which one is called.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 ExactBinding Types of the supplied arguments must exactly match the types of the corresponding formal parameters. Reflection throws an exception if the caller supplies a non-null Binder object, because that implies that the caller is supplying BindToXXX implementations that will pick the appropriate method. The default binder ignores this flag, whereas custom binders can implement the semantics of this flag.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 SuppressChangeType Not implemented.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 OptionalParamBinding The set of members whose parameter count matches the number of supplied arguments should be returned. This binding flag is used for methods with parameters that have default values and methods with variable arguments (varargs). This flag should only be used with the Type.InvokeMember method. Parameters with default values are used only in calls where trailing arguments are omitted. They must be the last arguments.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 IgnoreReturn Used in COM interop to specify that the return value of the member can be ignored.

Remarks

The flags specified by the BindingFlags enumeration control binding for many operations performed by classes in the System and System.Reflection namespaces. Under the general heading of reflection, these operations invoke, create, get, set, and find members and types. For example, binding flags are used in overloads of the following methods of Type, Activator, and MethodBase:

InvokeMember and GetMethod are especially important.

The binding flags can be categorized by how they identify a type member, as listed in the following table.

Identified by accessibility

Identified by binding argument

Identified by operation

DeclaredOnly

FlattenHierarchy

IgnoreCase

IgnoreReturn

Instance

NonPublic

Public

Static

ExactBinding

OptionalParamBinding

CreateInstance

GetField

SetField

GetProperty

SetProperty

InvokeMethod

PutDispProperty

PutRefDispProperty

NoteNote:

You must specify Instance or Static along with Public or NonPublic. Otherwise, no members will be returned.

The following table lists the coercions performed by the default Binder.ChangeType method. This table applies especially to the ExactBinding binding flag.

Source type

Target type

Any type

Its base type.

Any type

The interface it implements.

Char

UInt16, UInt32, Int32, UInt64, Int64, Single, Double

Byte

Char, UInt16, Int16, UInt32, Int32, UInt64, Int64, Single, Double

SByte

Int16, Int32, Int64, Single, Double

UInt16

UInt32, Int32, UInt64, Int64, Single, Double

Int16

Int32, Int64, Single, Double

UInt32

UInt64, Int64, Single, Double

Int32

Int64, Single, Double

UInt64

Single, Double

Int64

Single, Double

Single

Double

Non-reference

By-reference.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference