Reference documentation and code samples for the Firestore API class FieldValue.
A static class providing properties and methods to represent sentinel values.
Sentinel values are special values where the client-side value is not part of the
document modification sent to the server. A property decorated with
FirestorePropertyAttribute can specify an additional attribute
to indicate that it's a sentinel value, such as aServerTimestampAttribute,
or the sentinel values returned by the members of this class can be used directly as
values to be serialized (for example, in anonymous types), and they will be handled
directly by the serialization mechanism.
public static object ArrayRemove(params object[] values)
Creates a sentinel value to indicate the removal of the given values with an array.
This overload assumes that any custom serializers are configured via attributes. Use the overload
accepting a FirestoreDb if you need to use database-registered custom serializers.
public static object ArrayUnion(params object[] values)
Creates a sentinel value to indicate the union of the given values with an array.
This overload assumes that any custom serializers are configured via attributes. Use the overload
accepting a FirestoreDb if you need to use database-registered custom serializers.
If the current value is an integer or a double, both the current and the given value will be
interpreted as doubles and all arithmetic will follow IEEE 754 semantics.Otherwise, the
transformation will set the field to the given value.
Increment(long)
public static object Increment(long amount)
Creates a sentinel value to indicate an increment by the given value.
If the current field value is an integer, possible integer overflows are resolved to
MaxValue or MinValue. If the current field value
is a double, both values will be interpreted as doubles and the arithmetic will follow IEEE 754 semantics.
If the current field is not an integer or double, or if the field does not yet exist, the
transformation will set the field to the given value.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe latest version of the \u003ccode\u003eFieldValue\u003c/code\u003e class is 3.10.0, with a comprehensive history of versions from 3.9.0 back to 2.3.1 available for reference.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eFieldValue\u003c/code\u003e is a static class in the Firestore API, serving to represent special sentinel values that are used in server-side document modifications.\u003c/p\u003e\n"],["\u003cp\u003eThe class includes sentinel properties like \u003ccode\u003eDelete\u003c/code\u003e and \u003ccode\u003eServerTimestamp\u003c/code\u003e, and are used directly in the serialization process within Firestore.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eFieldValue\u003c/code\u003e offers methods like \u003ccode\u003eArrayRemove\u003c/code\u003e, \u003ccode\u003eArrayUnion\u003c/code\u003e, and \u003ccode\u003eIncrement\u003c/code\u003e to help users manage array operations and numeric increments within the Firestore database.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eIncrement\u003c/code\u003e method allows for the modification of the current field value by a double or long amount, applying different rules based on the type of the existing value.\u003c/p\u003e\n"]]],[],null,["# Firestore API - Class FieldValue (3.10.0)\n\nVersion latestkeyboard_arrow_down\n\n- [3.10.0 (latest)](/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.FieldValue)\n- [3.9.0](/dotnet/docs/reference/Google.Cloud.Firestore/3.9.0/Google.Cloud.Firestore.FieldValue)\n- [3.8.0](/dotnet/docs/reference/Google.Cloud.Firestore/3.8.0/Google.Cloud.Firestore.FieldValue)\n- [3.7.0](/dotnet/docs/reference/Google.Cloud.Firestore/3.7.0/Google.Cloud.Firestore.FieldValue)\n- [3.6.0](/dotnet/docs/reference/Google.Cloud.Firestore/3.6.0/Google.Cloud.Firestore.FieldValue)\n- [3.5.1](/dotnet/docs/reference/Google.Cloud.Firestore/3.5.1/Google.Cloud.Firestore.FieldValue)\n- [3.4.0](/dotnet/docs/reference/Google.Cloud.Firestore/3.4.0/Google.Cloud.Firestore.FieldValue)\n- [3.3.0](/dotnet/docs/reference/Google.Cloud.Firestore/3.3.0/Google.Cloud.Firestore.FieldValue)\n- [3.2.0](/dotnet/docs/reference/Google.Cloud.Firestore/3.2.0/Google.Cloud.Firestore.FieldValue)\n- [3.1.0](/dotnet/docs/reference/Google.Cloud.Firestore/3.1.0/Google.Cloud.Firestore.FieldValue)\n- [3.0.0](/dotnet/docs/reference/Google.Cloud.Firestore/3.0.0/Google.Cloud.Firestore.FieldValue)\n- [2.5.0](/dotnet/docs/reference/Google.Cloud.Firestore/2.5.0/Google.Cloud.Firestore.FieldValue)\n- [2.4.0](/dotnet/docs/reference/Google.Cloud.Firestore/2.4.0/Google.Cloud.Firestore.FieldValue)\n- [2.3.1](/dotnet/docs/reference/Google.Cloud.Firestore/2.3.1/Google.Cloud.Firestore.FieldValue) \n\n public static class FieldValue\n\nReference documentation and code samples for the Firestore API class FieldValue.\n\nA static class providing properties and methods to represent sentinel values.\nSentinel values are special values where the client-side value is not part of the\ndocument modification sent to the server. A property decorated with\n[FirestorePropertyAttribute](/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.FirestorePropertyAttribute) can specify an additional attribute\nto indicate that it's a sentinel value, such as a[ServerTimestampAttribute](/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.ServerTimestampAttribute),\nor the sentinel values returned by the members of this class can be used directly as\nvalues to be serialized (for example, in anonymous types), and they will be handled\ndirectly by the serialization mechanism. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e FieldValue \n\nInherited Members\n-----------------\n\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.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Firestore](/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore)\n\nAssembly\n--------\n\nGoogle.Cloud.Firestore.dll\n\nProperties\n----------\n\n### Delete\n\n public static object Delete { get; }\n\nSentinel value indicating that the field should be deleted from the document.\n\n### ServerTimestamp\n\n public static object ServerTimestamp { get; }\n\nSentinel value indicating that the field should be set to the timestamp of the\ncommit that creates or modifies the document.\n\nMethods\n-------\n\n### ArrayRemove(FirestoreDb, params object\\[\\])\n\n public static object ArrayRemove(FirestoreDb database, params object[] values)\n\nCreates a sentinel value to indicate the removal of the given values with an array. This over\n\n### ArrayRemove(params object\\[\\])\n\n public static object ArrayRemove(params object[] values)\n\nCreates a sentinel value to indicate the removal of the given values with an array.\nThis overload assumes that any custom serializers are configured via attributes. Use the overload\naccepting a [FirestoreDb](/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.FirestoreDb) if you need to use database-registered custom serializers.\n\n### ArrayUnion(FirestoreDb, params object\\[\\])\n\n public static object ArrayUnion(FirestoreDb database, params object[] values)\n\nCreates a sentinel value to indicate the union of the given values with an array.\n\n### ArrayUnion(params object\\[\\])\n\n public static object ArrayUnion(params object[] values)\n\nCreates a sentinel value to indicate the union of the given values with an array.\nThis overload assumes that any custom serializers are configured via attributes. Use the overload\naccepting a [FirestoreDb](/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.FirestoreDb) if you need to use database-registered custom serializers.\n\n### Increment(double)\n\n public static object Increment(double amount)\n\nCreates a sentinel value to indicate an increment by the given value.\n\n**Remarks** \n\nIf the current value is an integer or a double, both the current and the given value will be\ninterpreted as doubles and all arithmetic will follow IEEE 754 semantics.Otherwise, the\ntransformation will set the field to the given value.\n\n### Increment(long)\n\n public static object Increment(long amount)\n\nCreates a sentinel value to indicate an increment by the given value.\n\n**Remarks** \n\nIf the current field value is an integer, possible integer overflows are resolved to\n[MaxValue](https://learn.microsoft.com/dotnet/api/system.int64.maxvalue) or [MinValue](https://learn.microsoft.com/dotnet/api/system.int64.minvalue). If the current field value\nis a double, both values will be interpreted as doubles and the arithmetic will follow IEEE 754 semantics.\n\n\nIf the current field is not an integer or double, or if the field does not yet exist, the\ntransformation will set the field to the given value."]]