Metadata key. Gets converted to lowercase. Needs to have-binsuffix indicating a binary-valued metadata entry. The binary header suffix can be added to the key withBinaryHeaderSuffix. Can only contain lowercase alphanumeric characters, underscores, hyphens, and dots.
Metadata key. Gets converted to lowercase. Must not use-binsuffix indicating a binary-valued metadata entry. Can only contain lowercase alphanumeric characters, underscores, hyphens, and dots.
Gets the string value of the last metadata entry with the specified key.
If the metadata entry is binary then an exception is thrown.
If there are no matching entries thennullis returned.
Gets the bytes value of the last metadata entry with the specified key.
If the metadata entry is not binary the string value will be returned as ASCII encoded bytes.
If there are no matching entries thennullis returned.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003e\u003ccode\u003eMetadata\u003c/code\u003e is a collection of entries exchanged during gRPC calls, supporting request headers, response headers, and response trailers.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eMetadata\u003c/code\u003e class implements \u003ccode\u003eIList\u003c/code\u003e, \u003ccode\u003eICollection\u003c/code\u003e, and \u003ccode\u003eIEnumerable\u003c/code\u003e for \u003ccode\u003eMetadata.Entry\u003c/code\u003e, allowing for manipulation and traversal of metadata entries.\u003c/p\u003e\n"],["\u003cp\u003eMetadata entries can be added with either string keys and string values for ASCII data, or with string keys and byte arrays for binary data, where binary header keys need to have the \u003ccode\u003e-bin\u003c/code\u003e suffix.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve specific metadata entries using \u003ccode\u003eGet\u003c/code\u003e for the last entry with a given key, \u003ccode\u003eGetAll\u003c/code\u003e for all entries with a key, \u003ccode\u003eGetValue\u003c/code\u003e for string values, or \u003ccode\u003eGetValueBytes\u003c/code\u003e for byte values, while \u003ccode\u003eEmpty\u003c/code\u003e is a static, read-only instance of metadata with no entries.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eBinaryHeaderSuffix\u003c/code\u003e constant (\u003ccode\u003e-bin\u003c/code\u003e) is used to denote that a metadata key is for a binary-valued entry, and that all binary header keys should be appended with this suffix.\u003c/p\u003e\n"]]],[],null,["# Class Metadata (2.66.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.66.0 (latest)](/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Metadata)\n- [2.63.0](/dotnet/docs/reference/Grpc.Core/2.63.0/Grpc.Core.Metadata)\n- [2.48.0](/dotnet/docs/reference/Grpc.Core/2.48.0/Grpc.Core.Metadata) \n\n public sealed class Metadata : IList\u003cMetadata.Entry\u003e, ICollection\u003cMetadata.Entry\u003e, IEnumerable\u003cMetadata.Entry\u003e, IEnumerable\n\nA collection of metadata entries that can be exchanged during a call.\ngRPC supports these types of metadata:\n\n- Request headersare sent by the client at the beginning of a remote call before any request messages are sent.\n- Response headersare sent by the server at the beginning of a remote call handler before any response messages are sent.\n- Response trailersare sent by the server at the end of a remote call along with resulting call status.\n\n\u003cbr /\u003e\n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e Metadata \n\nImplements\n----------\n\n[IList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist-1)[Metadata](/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Metadata)[Entry](/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Metadata.Entry), [ICollection](https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1)[Metadata](/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Metadata)[Entry](/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Metadata.Entry), [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)[Metadata](/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Metadata)[Entry](/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Metadata.Entry), [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.ienumerable) \n\nInherited Members\n-----------------\n\n[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) \n[object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) \n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Grpc.Core](/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core)\n\nAssembly\n--------\n\nGrpc.Core.Api.dll\n\nConstructors\n------------\n\n### Metadata()\n\n public Metadata()\n\nInitializes a new instance of `Metadata`.\n\nFields\n------\n\n### BinaryHeaderSuffix\n\n public const string BinaryHeaderSuffix = \"-bin\"\n\nAll binary headers should have this suffix.\n\n### Empty\n\n public static readonly Metadata Empty\n\nAn read-only instance of metadata containing no entries.\n\nProperties\n----------\n\n### Count\n\n public int Count { get; }\n\nIList\\`1\n\n### IsReadOnly\n\n public bool IsReadOnly { get; }\n\nIList\\`1\n\n### this\\[int\\]\n\n public Metadata.Entry this[int index] { get; set; }\n\nIList\\`1\n\nMethods\n-------\n\n### Add(Entry)\n\n public void Add(Metadata.Entry item)\n\nIList\\`1\n\n### Add(string, byte\\[\\])\n\n public void Add(string key, byte[] valueBytes)\n\nAdds a new binary-valued metadata entry.\n\n### Add(string, string)\n\n public void Add(string key, string value)\n\nAdds a new ASCII-valued metadata entry.\n\n### Clear()\n\n public void Clear()\n\nIList\\`1\n\n### Contains(Entry)\n\n public bool Contains(Metadata.Entry item)\n\nIList\\`1\n\n### CopyTo(Entry\\[\\], int)\n\n public void CopyTo(Metadata.Entry[] array, int arrayIndex)\n\nIList\\`1\n\n### Get(string)\n\n public Metadata.Entry? Get(string key)\n\nGets the last metadata entry with the specified key.\nIf there are no matching entries then `null` is returned.\n\n### GetAll(string)\n\n public IEnumerable\u003cMetadata.Entry\u003e GetAll(string key)\n\nGets all metadata entries with the specified key.\n\n### GetEnumerator()\n\n public IEnumerator\u003cMetadata.Entry\u003e GetEnumerator()\n\nIList\\`1\n\n### GetValue(string)\n\n public string? GetValue(string key)\n\nGets the string value of the last metadata entry with the specified key.\nIf the metadata entry is binary then an exception is thrown.\nIf there are no matching entries then `null` is returned.\n\n### GetValueBytes(string)\n\n public byte[]? GetValueBytes(string key)\n\nGets the bytes value of the last metadata entry with the specified key.\nIf the metadata entry is not binary the string value will be returned as ASCII encoded bytes.\nIf there are no matching entries then `null` is returned.\n\n### IndexOf(Entry)\n\n public int IndexOf(Metadata.Entry item)\n\nIList\\`1\n\n### Insert(int, Entry)\n\n public void Insert(int index, Metadata.Entry item)\n\nIList\\`1\n\n### Remove(Entry)\n\n public bool Remove(Metadata.Entry item)\n\nIList\\`1\n\n### RemoveAt(int)\n\n public void RemoveAt(int index)\n\nIList\\`1"]]