What is the difference between Tuple and ValueTuple in C#?
Quick Answer
Tuple (System.Tuple) is a reference type with Item1, Item2… — heap-allocated, immutable, no names. ValueTuple (the (int, string) syntax) is a mutable value type with named elements, no allocation, and supports deconstruction. Use ValueTuple for lightweight multi-value returns.
The old System.Tuple is a class — it allocates on the heap and its members are just Item1, Item2 with no meaningful names. ValueTuple, which is the (int count, string name) syntax, is a struct so there's no allocation, and you can name the elements and deconstruct them. I use it for returning a couple of values from a private method — (bool ok, string error). For anything that's part of a public API I'd use a small record instead, because a named type documents itself.
public (bool ok, string? error) Validate(...)thenvar (ok, error) = Validate(...);.ValueTupleelement names are compile-time only (erased in the assembly / reflection).- For a public API surface, a small
recordor a purpose-named type is clearer than a tuple return. - Tuples are great inside a method or for private helpers; avoid deeply nested tuples.