[[["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\u003eFieldCodec is a static class within the Google.Protobuf namespace that provides factory methods for creating FieldCodec<T> instances.\u003c/p\u003e\n"],["\u003cp\u003eThe primary function of FieldCodec is to retrieve codecs for various data types (such as bool, bytes, double, enum, int, string, and more) based on a given tag.\u003c/p\u003e\n"],["\u003cp\u003eMethods within FieldCodec often allow specifying a default value for the field, as well as the tag to create a codec suitable for the field.\u003c/p\u003e\n"],["\u003cp\u003eFieldCodec also supports wrapper types for both classes and structs, allowing encoding and decoding for classes which must be string or ByteString, or structs that must be Int32, Int64, UInt32, UInt64, Bool, Single or Double.\u003c/p\u003e\n"],["\u003cp\u003eThe class inherits from \u003ccode\u003eobject\u003c/code\u003e, and has no public constructors or instance members, only static methods, with the listed versions of Google.Protobuf being 3.27.1 (latest), 3.23.0, and 3.15.8.\u003c/p\u003e\n"]]],[],null,["# Class FieldCodec (3.27.1)\n\nVersion latestkeyboard_arrow_down\n\n- [3.27.1 (latest)](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.FieldCodec)\n- [3.23.0](/dotnet/docs/reference/Google.Protobuf/3.23.0/Google.Protobuf.FieldCodec)\n- [3.15.8](/dotnet/docs/reference/Google.Protobuf/3.15.8/Google.Protobuf.FieldCodec) \n\n public static class FieldCodec\n\nFactory methods for [FieldCodec\\\u003cT\\\u003e](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.FieldCodec-1). \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e FieldCodec \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.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) \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[Google.Protobuf](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf)\n\nAssembly\n--------\n\nGoogle.Protobuf.dll\n\nMethods\n-------\n\n### ForBool(uint)\n\n public static FieldCodec\u003cbool\u003e ForBool(uint tag)\n\nRetrieves a codec suitable for a bool field with the given tag.\n\n### ForBool(uint, bool)\n\n public static FieldCodec\u003cbool\u003e ForBool(uint tag, bool defaultValue)\n\nRetrieves a codec suitable for a bool field with the given tag.\n\n### ForBytes(uint)\n\n public static FieldCodec\u003cByteString\u003e ForBytes(uint tag)\n\nRetrieves a codec suitable for a bytes field with the given tag.\n\n### ForBytes(uint, ByteString)\n\n public static FieldCodec\u003cByteString\u003e ForBytes(uint tag, ByteString defaultValue)\n\nRetrieves a codec suitable for a bytes field with the given tag.\n\n### ForClassWrapper\\\u003cT\\\u003e(uint)\n\n public static FieldCodec\u003cT\u003e ForClassWrapper\u003cT\u003e(uint tag) where T : class\n\nCreates a codec for a wrapper type of a class - which must be string or ByteString.\n\n### ForDouble(uint)\n\n public static FieldCodec\u003cdouble\u003e ForDouble(uint tag)\n\nRetrieves a codec suitable for a double field with the given tag.\n\n### ForDouble(uint, double)\n\n public static FieldCodec\u003cdouble\u003e ForDouble(uint tag, double defaultValue)\n\nRetrieves a codec suitable for a double field with the given tag.\n\n### ForEnum\\\u003cT\\\u003e(uint, Func\\\u003cT, int\\\u003e, Func\\\u003cint, T\\\u003e)\n\n public static FieldCodec\u003cT\u003e ForEnum\u003cT\u003e(uint tag, Func\u003cT, int\u003e toInt32, Func\u003cint, T\u003e fromInt32)\n\nRetrieves a codec suitable for an enum field with the given tag.\n\n### ForEnum\\\u003cT\\\u003e(uint, Func\\\u003cT, int\\\u003e, Func\\\u003cint, T\\\u003e, T)\n\n public static FieldCodec\u003cT\u003e ForEnum\u003cT\u003e(uint tag, Func\u003cT, int\u003e toInt32, Func\u003cint, T\u003e fromInt32, T defaultValue)\n\nRetrieves a codec suitable for an enum field with the given tag.\n\n### ForFixed32(uint)\n\n public static FieldCodec\u003cuint\u003e ForFixed32(uint tag)\n\nRetrieves a codec suitable for a fixed32 field with the given tag.\n\n### ForFixed32(uint, uint)\n\n public static FieldCodec\u003cuint\u003e ForFixed32(uint tag, uint defaultValue)\n\nRetrieves a codec suitable for a fixed32 field with the given tag.\n\n### ForFixed64(uint)\n\n public static FieldCodec\u003culong\u003e ForFixed64(uint tag)\n\nRetrieves a codec suitable for a fixed64 field with the given tag.\n\n### ForFixed64(uint, ulong)\n\n public static FieldCodec\u003culong\u003e ForFixed64(uint tag, ulong defaultValue)\n\nRetrieves a codec suitable for a fixed64 field with the given tag.\n\n### ForFloat(uint)\n\n public static FieldCodec\u003cfloat\u003e ForFloat(uint tag)\n\nRetrieves a codec suitable for a float field with the given tag.\n\n### ForFloat(uint, float)\n\n public static FieldCodec\u003cfloat\u003e ForFloat(uint tag, float defaultValue)\n\nRetrieves a codec suitable for a float field with the given tag.\n\n### ForGroup\\\u003cT\\\u003e(uint, uint, MessageParser\\\u003cT\\\u003e)\n\n public static FieldCodec\u003cT\u003e ForGroup\u003cT\u003e(uint startTag, uint endTag, MessageParser\u003cT\u003e parser) where T : class, IMessage\u003cT\u003e\n\nRetrieves a codec suitable for a group field with the given tag.\n\n### ForInt32(uint)\n\n public static FieldCodec\u003cint\u003e ForInt32(uint tag)\n\nRetrieves a codec suitable for an int32 field with the given tag.\n\n### ForInt32(uint, int)\n\n public static FieldCodec\u003cint\u003e ForInt32(uint tag, int defaultValue)\n\nRetrieves a codec suitable for an int32 field with the given tag.\n\n### ForInt64(uint)\n\n public static FieldCodec\u003clong\u003e ForInt64(uint tag)\n\nRetrieves a codec suitable for an int64 field with the given tag.\n\n### ForInt64(uint, long)\n\n public static FieldCodec\u003clong\u003e ForInt64(uint tag, long defaultValue)\n\nRetrieves a codec suitable for an int64 field with the given tag.\n\n### ForMessage\\\u003cT\\\u003e(uint, MessageParser\\\u003cT\\\u003e)\n\n public static FieldCodec\u003cT\u003e ForMessage\u003cT\u003e(uint tag, MessageParser\u003cT\u003e parser) where T : class, IMessage\u003cT\u003e\n\nRetrieves a codec suitable for a message field with the given tag.\n\n### ForSFixed32(uint)\n\n public static FieldCodec\u003cint\u003e ForSFixed32(uint tag)\n\nRetrieves a codec suitable for an sfixed32 field with the given tag.\n\n### ForSFixed32(uint, int)\n\n public static FieldCodec\u003cint\u003e ForSFixed32(uint tag, int defaultValue)\n\nRetrieves a codec suitable for an sfixed32 field with the given tag.\n\n### ForSFixed64(uint)\n\n public static FieldCodec\u003clong\u003e ForSFixed64(uint tag)\n\nRetrieves a codec suitable for an sfixed64 field with the given tag.\n\n### ForSFixed64(uint, long)\n\n public static FieldCodec\u003clong\u003e ForSFixed64(uint tag, long defaultValue)\n\nRetrieves a codec suitable for an sfixed64 field with the given tag.\n\n### ForSInt32(uint)\n\n public static FieldCodec\u003cint\u003e ForSInt32(uint tag)\n\nRetrieves a codec suitable for an sint32 field with the given tag.\n\n### ForSInt32(uint, int)\n\n public static FieldCodec\u003cint\u003e ForSInt32(uint tag, int defaultValue)\n\nRetrieves a codec suitable for an sint32 field with the given tag.\n\n### ForSInt64(uint)\n\n public static FieldCodec\u003clong\u003e ForSInt64(uint tag)\n\nRetrieves a codec suitable for an sint64 field with the given tag.\n\n### ForSInt64(uint, long)\n\n public static FieldCodec\u003clong\u003e ForSInt64(uint tag, long defaultValue)\n\nRetrieves a codec suitable for an sint64 field with the given tag.\n\n### ForString(uint)\n\n public static FieldCodec\u003cstring\u003e ForString(uint tag)\n\nRetrieves a codec suitable for a string field with the given tag.\n\n### ForString(uint, string)\n\n public static FieldCodec\u003cstring\u003e ForString(uint tag, string defaultValue)\n\nRetrieves a codec suitable for a string field with the given tag.\n\n### ForStructWrapper\\\u003cT\\\u003e(uint)\n\n public static FieldCodec\u003cT?\u003e ForStructWrapper\u003cT\u003e(uint tag) where T : struct\n\nCreates a codec for a wrapper type of a struct - which must be Int32, Int64, UInt32, UInt64,\nBool, Single or Double.\n\n### ForUInt32(uint)\n\n public static FieldCodec\u003cuint\u003e ForUInt32(uint tag)\n\nRetrieves a codec suitable for a uint32 field with the given tag.\n\n### ForUInt32(uint, uint)\n\n public static FieldCodec\u003cuint\u003e ForUInt32(uint tag, uint defaultValue)\n\nRetrieves a codec suitable for a uint32 field with the given tag.\n\n### ForUInt64(uint)\n\n public static FieldCodec\u003culong\u003e ForUInt64(uint tag)\n\nRetrieves a codec suitable for a uint64 field with the given tag.\n\n### ForUInt64(uint, ulong)\n\n public static FieldCodec\u003culong\u003e ForUInt64(uint tag, ulong defaultValue)\n\nRetrieves a codec suitable for a uint64 field with the given tag."]]