MemberInfoExtensions.GetMetadataToken(MemberInfo) Method

Definition

Gets a metadata token for the given member, if available.

C#
public static int GetMetadataToken(this System.Reflection.MemberInfo member);

Parameters

member
MemberInfo

The member from which to retrieve the token, as reftype.

Returns

An integer representing the metadata token. The returned token is never nil. If unavailable, an exception is thrown.

Exceptions

There is no metadata token available.

Remarks

This method throws an exception if a metadata token is not available for the specified member. You can call HasMetadataToken to determine whether a metadata token is available before calling this method.

Applies to

Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)