英語で読む 編集

次の方法で共有


TypedReference.MakeTypedReference(Object, FieldInfo[]) Method

Definition

Important

This API is not CLS-compliant.

Makes a TypedReference for a field identified by a specified object and list of field descriptions.

C#
public static TypedReference MakeTypedReference(object target, System.Reflection.FieldInfo[] flds);
C#
[System.CLSCompliant(false)]
public static TypedReference MakeTypedReference(object target, System.Reflection.FieldInfo[] flds);
C#
[System.CLSCompliant(false)]
[System.Security.SecurityCritical]
public static TypedReference MakeTypedReference(object target, System.Reflection.FieldInfo[] flds);

Parameters

target
Object

An object that contains the field described by the first element of flds.

flds
FieldInfo[]

A list of field descriptions where each element describes a field that contains the field described by the succeeding element. Each described field must be a value type. The field descriptions must be RuntimeFieldInfo objects supplied by the type system.

Returns

A TypedReference for the field described by the last element of flds.

Attributes

Exceptions

target or flds is null.

-or-

An element of flds is null.

The flds array has no elements.

-or-

An element of flds is not a RuntimeFieldInfo object.

-or-

The IsInitOnly or IsStatic property of an element of flds is true.

Parameter target does not contain the field described by the first element of flds, or an element of flds describes a field that is not contained in the field described by the succeeding element of flds.

-or-

The field described by an element of flds is not a value type.

Remarks

The MakeTypedReference method returns a typed reference to some terminal field, where the target parameter contains the field described by the first element of flds, the field described by the first element of flds contains the field described by the second element of flds, and so on until the terminal field is reached.

注意

Starting with the .NET Framework 2.0 Service Pack 1, this method can be used to access non-public members if the caller has been granted ReflectionPermission with the ReflectionPermissionFlag.RestrictedMemberAccess flag and if the grant set of the non-public members is restricted to the caller's grant set, or a subset thereof. (See Security Considerations for Reflection.)

To use this functionality, your application should target the .NET Framework 3.5 or later.

Applies to

製品 バージョン
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1