public sealed class BitSequence : IMessage<BitSequence>, IEquatable<BitSequence>, IDeepCloneable<BitSequence>, IBufferMessage, IMessage
Reference documentation and code samples for the Firestore v1 API class BitSequence.
A sequence of bits, encoded in a byte array.
Each byte in the bitmap byte array stores 8 bits of the sequence. The only
exception is the last byte, which may store 8 or fewer bits. The padding
defines the number of bits of the last byte to be ignored as "padding". The
values of these "padding" bits are unspecified and must be ignored.
To retrieve the first bit, bit 0, calculate: (bitmap[0] & 0x01) != 0.
To retrieve the second bit, bit 1, calculate: (bitmap[0] & 0x02) != 0.
To retrieve the third bit, bit 2, calculate: (bitmap[0] & 0x04) != 0.
To retrieve the fourth bit, bit 3, calculate: (bitmap[0] & 0x08) != 0.
To retrieve bit n, calculate: (bitmap[n / 8] & (0x01 << (n % 8))) != 0.
The "size" of a BitSequence (the number of bits it contains) is calculated
by this formula: (bitmap.length * 8) - padding.
The number of bits of the last byte in bitmap to ignore as "padding".
If the length of bitmap is zero, then this value must be 0.
Otherwise, this value must be between 0 and 7, inclusive.
[[["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-08-28 UTC."],[[["\u003cp\u003eThis webpage provides reference documentation for the \u003ccode\u003eBitSequence\u003c/code\u003e class within the Google Cloud Firestore v1 API for .NET.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eBitSequence\u003c/code\u003e is a class used to represent a sequence of bits, encoded within a byte array, where each byte stores 8 bits, except the last one.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eBitSequence\u003c/code\u003e class has a \u003ccode\u003eBitmap\u003c/code\u003e property which represents the encoded bytes and a \u003ccode\u003ePadding\u003c/code\u003e property indicating the number of padding bits in the last byte.\u003c/p\u003e\n"],["\u003cp\u003eThe documentation includes different versions of the \u003ccode\u003eBitSequence\u003c/code\u003e class, from the latest 3.10.0 version down to version 2.3.0.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eBitSequence\u003c/code\u003e class implements multiple interfaces like IMessage, IEquatable, IDeepCloneable, and IBufferMessage and inherits members from the base object class.\u003c/p\u003e\n"]]],[],null,["# Firestore v1 API - Class BitSequence (3.10.0)\n\nVersion latestkeyboard_arrow_down\n\n- [3.10.0 (latest)](/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BitSequence)\n- [3.9.0](/dotnet/docs/reference/Google.Cloud.Firestore.V1/3.9.0/Google.Cloud.Firestore.V1.BitSequence)\n- [3.8.0](/dotnet/docs/reference/Google.Cloud.Firestore.V1/3.8.0/Google.Cloud.Firestore.V1.BitSequence)\n- [3.7.0](/dotnet/docs/reference/Google.Cloud.Firestore.V1/3.7.0/Google.Cloud.Firestore.V1.BitSequence)\n- [3.6.0](/dotnet/docs/reference/Google.Cloud.Firestore.V1/3.6.0/Google.Cloud.Firestore.V1.BitSequence)\n- [3.5.1](/dotnet/docs/reference/Google.Cloud.Firestore.V1/3.5.1/Google.Cloud.Firestore.V1.BitSequence)\n- [3.4.0](/dotnet/docs/reference/Google.Cloud.Firestore.V1/3.4.0/Google.Cloud.Firestore.V1.BitSequence)\n- [3.3.0](/dotnet/docs/reference/Google.Cloud.Firestore.V1/3.3.0/Google.Cloud.Firestore.V1.BitSequence)\n- [3.2.0](/dotnet/docs/reference/Google.Cloud.Firestore.V1/3.2.0/Google.Cloud.Firestore.V1.BitSequence)\n- [3.1.0](/dotnet/docs/reference/Google.Cloud.Firestore.V1/3.1.0/Google.Cloud.Firestore.V1.BitSequence)\n- [3.0.0](/dotnet/docs/reference/Google.Cloud.Firestore.V1/3.0.0/Google.Cloud.Firestore.V1.BitSequence)\n- [2.5.0](/dotnet/docs/reference/Google.Cloud.Firestore.V1/2.5.0/Google.Cloud.Firestore.V1.BitSequence)\n- [2.4.0](/dotnet/docs/reference/Google.Cloud.Firestore.V1/2.4.0/Google.Cloud.Firestore.V1.BitSequence)\n- [2.3.0](/dotnet/docs/reference/Google.Cloud.Firestore.V1/2.3.0/Google.Cloud.Firestore.V1.BitSequence) \n\n public sealed class BitSequence : IMessage\u003cBitSequence\u003e, IEquatable\u003cBitSequence\u003e, IDeepCloneable\u003cBitSequence\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Firestore v1 API class BitSequence.\n\nA sequence of bits, encoded in a byte array.\n\nEach byte in the `bitmap` byte array stores 8 bits of the sequence. The only\nexception is the last byte, which may store 8 *or fewer* bits. The `padding`\ndefines the number of bits of the last byte to be ignored as \"padding\". The\nvalues of these \"padding\" bits are unspecified and must be ignored.\n\nTo retrieve the first bit, bit 0, calculate: `(bitmap[0] & 0x01) != 0`.\nTo retrieve the second bit, bit 1, calculate: `(bitmap[0] & 0x02) != 0`.\nTo retrieve the third bit, bit 2, calculate: `(bitmap[0] & 0x04) != 0`.\nTo retrieve the fourth bit, bit 3, calculate: `(bitmap[0] & 0x08) != 0`.\nTo retrieve bit n, calculate: `(bitmap[n / 8] & (0x01 \u003c\u003c (n % 8))) != 0`.\n\nThe \"size\" of a `BitSequence` (the number of bits it contains) is calculated\nby this formula: `(bitmap.length * 8) - padding`. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e BitSequence \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[BitSequence](/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BitSequence), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[BitSequence](/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BitSequence), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[BitSequence](/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1.BitSequence), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \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.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Firestore.V1](/dotnet/docs/reference/Google.Cloud.Firestore.V1/latest/Google.Cloud.Firestore.V1)\n\nAssembly\n--------\n\nGoogle.Cloud.Firestore.V1.dll\n\nConstructors\n------------\n\n### BitSequence()\n\n public BitSequence()\n\n### BitSequence(BitSequence)\n\n public BitSequence(BitSequence other)\n\nProperties\n----------\n\n### Bitmap\n\n public ByteString Bitmap { get; set; }\n\nThe bytes that encode the bit sequence.\nMay have a length of zero.\n\n### Padding\n\n public int Padding { get; set; }\n\nThe number of bits of the last byte in `bitmap` to ignore as \"padding\".\nIf the length of `bitmap` is zero, then this value must be `0`.\nOtherwise, this value must be between 0 and 7, inclusive."]]