TypedReference.MakeTypedReference(Object, FieldInfo[]) 方法

定義

重要

此 API 不符合 CLS 規範。

對由指定物件和欄位描述清單所識別的欄位產生 TypedReferenceMakes a TypedReference for a field identified by a specified object and list of field descriptions.

public:
 static TypedReference MakeTypedReference(System::Object ^ target, cli::array <System::Reflection::FieldInfo ^> ^ flds);
[System.CLSCompliant(false)]
[System.Security.SecurityCritical]
public static TypedReference MakeTypedReference (object target, System.Reflection.FieldInfo[] flds);
static member MakeTypedReference : obj * System.Reflection.FieldInfo[] -> TypedReference
Public Shared Function MakeTypedReference (target As Object, flds As FieldInfo()) As TypedReference

參數

target
Object

物件,包含由 flds 的第一元素所描述的欄位。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. 欄位描述必須是由型別系統所提供的 RuntimeFieldInfo 物件。The field descriptions must be RuntimeFieldInfo objects supplied by the type system.

傳回

flds 最後一個元素所描述之欄位的 TypedReferenceA TypedReference for the field described by the last element of flds.

屬性

例外狀況

targetfldsnulltarget or flds is null.

-或--or- flds 的項目是 nullAn element of flds is null.

flds 陣列沒有任何項目。The flds array has no elements.

-或--or- flds 的元素不是 RuntimeFieldInfo 物件。An element of flds is not a RuntimeFieldInfo object.

-或--or- flds 之項目的 IsInitOnlyIsStatic 屬性為 trueThe IsInitOnly or IsStatic property of an element of flds is true.

參數 target 不包含由 flds 的第一個項目所描述的欄位,或是 flds 的項目描述不包含於 flds 的接續項目所描述之欄位中的欄位。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- flds 的項目所描述的欄位不是實值類型。The field described by an element of flds is not a value type.

備註

MakeTypedReference 方法會傳回某個終端機欄位的具型別參考,其中 target 參數包含 flds的第一個元素所描述的欄位、flds 的第一個元素所描述的欄位,其中包含第二個 flds元素所描述的欄位,依此類推,直到到達終端機欄位為止。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.

注意

.NET Framework 2.0 Service Pack 1.NET Framework 2.0 Service Pack 1開始,如果呼叫者已被授與 ReflectionPermissionFlag.RestrictedMemberAccess 旗標 ReflectionPermission,而且非公用成員的授與集受限於呼叫者的授與集或其子集,這個方法就可以用來存取非公用成員。Starting with the .NET Framework 2.0 Service Pack 1.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.)

若要使用這項功能,您的應用程式應將目標設為 .NET Framework 3.5.NET Framework 3.5 (含) 以後版本。To use this functionality, your application should target the .NET Framework 3.5.NET Framework 3.5 or later.

安全性

SecurityCriticalAttribute
需要完全信任立即呼叫者。Requires full trust for the immediate caller. 部分信任或透明的程式碼無法使用這個成員。This member cannot be used by partially trusted or transparent code.

適用於