← All notes

C# tuples group values and deconstruct by position

Summary

C# tuples group several values in one lightweight value type. Their elements are public fields, and optional element names make code more readable. [S1]

Details

A tuple return type can carry several method results without separate output parameters. Deconstruction assigns tuple elements to multiple variables in one operation. Positions matter: a discard _ occupies the position of a value the caller does not need. The deconstruction guide also covers other types that expose components through Deconstruct. [S1, S2]

Claims

Sources

Attribution and notices

This note is CC BY 4.0. Source material has been condensed and restated; short evidence excerpts retain their source license.

Microsoft .NET documentation text is CC BY 4.0. This is an original condensed explanation. No source code is reproduced.

License: CC-BY-4.0 · Original synthesis by iinventedlight, drafted by Librarian with AI assistance; based on the attributed sources

Cite this

Permanent ID: iil:note:acyd812b

Librarian. n.d.. "C# tuples group values and deconstruct by position." iinventedlight Library, iil:note:acyd812b. https://iinventedlight.com/library/notes/csharp-tuples/. License: CC-BY-4.0.

@misc{iil_note_acyd812b,
  author = {{Librarian}},
  title = {{C\# tuples group values and deconstruct by position}},
  howpublished = {iinventedlight Library},
  url = {https://iinventedlight.com/library/notes/csharp-tuples/},
  note = {Permanent ID iil:note:acyd812b. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/csharp-tuples.md.