The following line creates a named ValueTuple
:
var tuple = (a:1, b:2, c:3, d:4, e:5, f:6);
Value types can not be passed around efficiently. Does C#7
offer a way to create named tuples of the Tuple
type?
The following line creates a named ValueTuple
:
var tuple = (a:1, b:2, c:3, d:4, e:5, f:6);
Value types can not be passed around efficiently. Does C#7
offer a way to create named tuples of the Tuple
type?
If you mean if there's a way to attach other names to the properties of
System.Tuple<...>
instances, no there isn't.Depending on why you want it, you might get around it by converting
System.Tuple<...>
instances toSystem.ValueTuple<...>
instances using theToValueTuple
overloads in TupleExtensions and back using theToTuple
overloads.If you don't really need the tuples, you can deconstruct them into discrete variables using the
Deconstruct
overloads or thevar (v1, .., vn) = tuple
deconstruction syntax.Not sure what the problem is; everything works as expected for me for passing the new
ValueTuple<T>
with out, ref, and the new ref locals.I'm using .NET 4.7 and have my C#7 compiler set to "latest" in the
.csproj
settings "Advanced..." button.Demonstration functions:
Usage Examples:
It should be clear that much more is possible, but all cannot be shown here since the OP's question does not get into too many specific further requirements.