MetadataTokens.GetToken Method

Definition

Overloads

GetToken(MetadataReader, EntityHandle)

Gets the metadata token of the specified handle in the context of reader.

GetToken(MetadataReader, Handle)

Gets the metadata token of the specified handle in the context of reader.

GetToken(EntityHandle)

Gets the metadata token of the specified handle.

GetToken(Handle)

Gets the metadata token of the specified handle.

GetToken(MetadataReader, EntityHandle)

Source:
MetadataTokens.cs
Source:
MetadataTokens.cs
Source:
MetadataTokens.cs
Source:
MetadataTokens.cs

Gets the metadata token of the specified handle in the context of reader.

C#
public static int GetToken(this System.Reflection.Metadata.MetadataReader reader, System.Reflection.Metadata.EntityHandle handle);

Parameters

handle
EntityHandle

Returns

Metadata token.

Exceptions

The operation is not supported for the specified handle.

Applies to

.NET 10 and other versions
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 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

GetToken(MetadataReader, Handle)

Source:
MetadataTokens.cs
Source:
MetadataTokens.cs
Source:
MetadataTokens.cs
Source:
MetadataTokens.cs

Gets the metadata token of the specified handle in the context of reader.

C#
public static int GetToken(this System.Reflection.Metadata.MetadataReader reader, System.Reflection.Metadata.Handle handle);

Parameters

handle
Handle

Returns

Metadata token.

Exceptions

Handle represents a metadata entity that doesn't have a token. A token can only be retrieved for a metadata table handle or a heap handle of type UserString.

The operation is not supported for the specified handle.

Applies to

.NET 10 and other versions
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 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)
UWP 10.0

GetToken(EntityHandle)

Source:
MetadataTokens.cs
Source:
MetadataTokens.cs
Source:
MetadataTokens.cs
Source:
MetadataTokens.cs

Gets the metadata token of the specified handle.

C#
public static int GetToken(System.Reflection.Metadata.EntityHandle handle);

Parameters

handle
EntityHandle

Returns

Metadata token, or 0 if handle can only be interpreted in a context of a specific MetadataReader.

Applies to

.NET 10 and other versions
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 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

GetToken(Handle)

Source:
MetadataTokens.cs
Source:
MetadataTokens.cs
Source:
MetadataTokens.cs
Source:
MetadataTokens.cs

Gets the metadata token of the specified handle.

C#
public static int GetToken(System.Reflection.Metadata.Handle handle);

Parameters

handle
Handle

Returns

Metadata token, or 0 if handle can only be interpreted in a context of a specific MetadataReader.

Exceptions

Handle represents a metadata entity that doesn't have a token. A token can only be retrieved for a metadata table handle or a heap handle of type UserString.

Applies to

.NET 10 and other versions
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 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)
UWP 10.0