public sealed class SpannerStruct : IReadOnlyList<SpannerStruct.Field>, IReadOnlyCollection<SpannerStruct.Field>, IEnumerable<SpannerStruct.Field>, IEnumerable
Reference documentation and code samples for the Google.Cloud.Spanner.Data class SpannerStruct.
The name of the field. May be null, and does not need to be unique within the struct.
If the value is null, the SpannerStruct.Field value added will have an empty string for the name.
The SpannerDbType representing the schema of this struct.
Remarks
The returned object reflects the current fields in the struct. If more
fields are added later, those changes will not be visible via the returned value.
Instead, this method should be called again obtain the up-to-date schema.
[[["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-07 UTC."],[[["\u003cp\u003eThe latest version of the \u003ccode\u003eSpannerStruct\u003c/code\u003e class is \u003ccode\u003e5.0.0-beta05\u003c/code\u003e, with various older versions also documented, including stable releases and beta versions.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSpannerStruct\u003c/code\u003e is a class in the \u003ccode\u003eGoogle.Cloud.Spanner.Data\u003c/code\u003e namespace, used for representing a struct parameter or returned value, and it implements several interfaces, such as \u003ccode\u003eIReadOnlyList\u003c/code\u003e, \u003ccode\u003eIReadOnlyCollection\u003c/code\u003e, and \u003ccode\u003eIEnumerable\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eSpannerStruct\u003c/code\u003e class provides methods for adding fields, such as \u003ccode\u003eAdd(Field)\u003c/code\u003e and \u003ccode\u003eAdd(string, SpannerDbType, object)\u003c/code\u003e, and it also allows accessing fields by index via the \u003ccode\u003ethis[int index]\u003c/code\u003e property.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSpannerStruct\u003c/code\u003e objects can be enumerated to iterate through their fields using the \u003ccode\u003eGetEnumerator()\u003c/code\u003e method, and the \u003ccode\u003eGetSpannerDbType()\u003c/code\u003e method returns the full schema of the struct as a \u003ccode\u003eSpannerDbType\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSpannerStruct\u003c/code\u003e differs from a Google Protobuf struct because field names are optional and do not have to be unique.\u003c/p\u003e\n"]]],[],null,["# Google.Cloud.Spanner.Data - Class SpannerStruct (5.1.0)\n\nVersion latestkeyboard_arrow_down\n\n- [5.1.0 (latest)](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerStruct)\n- [5.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/5.0.0/Google.Cloud.Spanner.Data.SpannerStruct)\n- [4.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.6.0/Google.Cloud.Spanner.Data.SpannerStruct)\n- [4.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.5.0/Google.Cloud.Spanner.Data.SpannerStruct)\n- [4.4.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.4.0/Google.Cloud.Spanner.Data.SpannerStruct)\n- [4.3.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.3.0/Google.Cloud.Spanner.Data.SpannerStruct)\n- [4.2.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.2.0/Google.Cloud.Spanner.Data.SpannerStruct)\n- [4.1.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.1.0/Google.Cloud.Spanner.Data.SpannerStruct)\n- [4.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.0.0/Google.Cloud.Spanner.Data.SpannerStruct)\n- [3.15.1](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.15.1/Google.Cloud.Spanner.Data.SpannerStruct)\n- [3.14.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.14.0/Google.Cloud.Spanner.Data.SpannerStruct)\n- [3.13.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.13.0/Google.Cloud.Spanner.Data.SpannerStruct)\n- [3.12.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.12.0/Google.Cloud.Spanner.Data.SpannerStruct)\n- [3.11.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.11.0/Google.Cloud.Spanner.Data.SpannerStruct)\n- [3.10.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.10.0/Google.Cloud.Spanner.Data.SpannerStruct)\n- [3.9.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.9.0/Google.Cloud.Spanner.Data.SpannerStruct)\n- [3.8.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.8.0/Google.Cloud.Spanner.Data.SpannerStruct)\n- [3.7.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.7.0/Google.Cloud.Spanner.Data.SpannerStruct)\n- [3.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.6.0/Google.Cloud.Spanner.Data.SpannerStruct)\n- [3.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.5.0/Google.Cloud.Spanner.Data.SpannerStruct) \n\n public sealed class SpannerStruct : IReadOnlyList\u003cSpannerStruct.Field\u003e, IReadOnlyCollection\u003cSpannerStruct.Field\u003e, IEnumerable\u003cSpannerStruct.Field\u003e, IEnumerable\n\nReference documentation and code samples for the Google.Cloud.Spanner.Data class SpannerStruct.\n\nA struct parameter or returned value. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e SpannerStruct \n\nImplements\n----------\n\n[IReadOnlyList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist-1)[SpannerStruct](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerStruct)[Field](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerStruct.Field), [IReadOnlyCollection](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlycollection-1)[SpannerStruct](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerStruct)[Field](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerStruct.Field), [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)[SpannerStruct](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerStruct)[Field](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerStruct.Field), [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.ienumerable) \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.Spanner.Data](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data)\n\nAssembly\n--------\n\nGoogle.Cloud.Spanner.Data.dll\n\nRemarks\n-------\n\nA Spanner struct isn't exactly the same as a Google Protobuf struct:\n\n- Field names are optional\n- Field names do not have to be unique\n\n\u003cbr /\u003e\n\nProperties\n----------\n\n### Count\n\n public int Count { get; }\n\nReturns the number of fields currently in the struct.\n\n### this\\[int\\]\n\n public SpannerStruct.Field this[int index] { get; }\n\nReturns the field at the given index.\n\nMethods\n-------\n\n### Add(Field)\n\n public SpannerStruct.Field Add(SpannerStruct.Field field)\n\nAdds a new field to the struct.\n\n### Add(string, SpannerDbType, object)\n\n public SpannerStruct.Field Add(string name, SpannerDbType type, object value)\n\nAdds a new field to the struct with the given name, type and value.\n\n### GetEnumerator()\n\n public IEnumerator\u003cSpannerStruct.Field\u003e GetEnumerator()\n\nReturns an enumerator that iterates through the collection.\n\n### GetSpannerDbType()\n\n public SpannerDbType GetSpannerDbType()\n\nReturns the full schema of this struct as a [SpannerDbType](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerDbType).\n\n**Remarks** \nThe returned object reflects the current fields in the struct. If more\nfields are added later, those changes will not be visible via the returned value.\nInstead, this method should be called again obtain the up-to-date schema."]]