DEV Community

Discussion on: 5 Bad Practices That Can Make Your C# Code Messy - And How to Avoid Them

Collapse
 
chriz_ profile image
Chriz

The Tuples introduced with C# 7 are not always a better choice; they are value types, which means if your passing back a reference type, its going to 'copied' leave a bigger memory footprint.

There is a reference type version too:

C# tuples, which are backed by System.ValueTuple types, are different from tuples that are represented by System.Tuple types. The main differences are as follows:

-System.ValueTuple types are value types. System.Tuple types are reference types.
-System.ValueTuple types are mutable. System.Tuple types are immutable.
-Data members of System.ValueTuple types are fields. Data members of System.Tuple types are properties.