Questions tagged [valuetuple]

This covers the ValueTuple struct used by C#'s tuples

Value tuples are tuple types introduced in the .NET Framework 4.7 to provide the runtime implementation of tuples in C#. They are different from tuple classes, like Tuple<T1>, because they are value types, rather then reference ones.

141 questions
-1
votes
1 answer

LINQ Compund FROM cluase for separate objects

There is a more or less recent (Jan 2020) video on YouTube explaining how to use a compound where clause in LINQ. In this example, the where is used twice, but for objects that are not related. When I try this in Visual Studio 2017 (in a Program.cs…
VISQL
  • 1,960
  • 5
  • 29
  • 41
-1
votes
1 answer

How do I extract a value out of a dictionary that contains a value tuple as the key in C#?

The below code snippet initializes a Dictionary with a value tuple as key. How do I fetch the individual values after initializing? static void Main(string[] args) { Dictionary<(int, int), string> dict = new Dictionary<(int, int), string>(); …
Hank
  • 29
  • 3
-2
votes
1 answer

Easiest way to serialize an ValueTuple list

What's the easiest way to serialize and de-serialize an List<(string,string)>? , something that can be stored into an string column in an database table.
L4marr
  • 291
  • 2
  • 16
-2
votes
1 answer

Ienumerable.cast to ValueTuple InvalidCastException

I have this class named Point2D having two properties X and Y. This class has an implicit conversion to ValueTuple (double x, double y) My problem comes when I cast List() to List<(double x, double y)>() using Linq Ienumerable.Cast(), it…
Marlon Dumal-is
  • 300
  • 2
  • 13
-3
votes
1 answer

How to use the iterating variable after a foreach

foreach (var (counter, _, _) in Count()) { ... // do stuff with counter } return counter; counter's out of scope after the foreach so the above doesn't work. How can I use one of the iteration variables after a loop other than int…
theonlygusti
  • 11,032
  • 11
  • 64
  • 119
-4
votes
1 answer

Fastest way of incrementing an element of a List<(Guid, int)>

I have a List<(Guid, int)> (a list of value-tuples), and I want to increment the Item2 field of an element at a specified index. Based on the answers in this question, there are two ways to do it: The first is to get a copy of the existing (Guid,…
Theodor Zoulias
  • 34,835
  • 7
  • 69
  • 104
1 2 3
9
10