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
vote
1 answer

Polly.Caching.Memory.MemoryCacheProvider throws System.TypeLoadException : method not implemented for one application

I'm using these pacakges: PackageReference Include="Polly" Version="7.2.2" PackageReference Include="Polly.Caching.Memory" Version="3.0.2" I have a testproject that uses these packages and the code works. When I try to integrate my code in an…
Schwarzie2478
  • 2,186
  • 26
  • 30
1
vote
0 answers

How to extend a zero component tuple in C#

ValueTuples in C# are mutable. Is it possible to create a ValueTuple with no elements and then add elements to it at a later time? Kind of like how we can instantiate a list and add the list items afterward.
1
vote
1 answer

How to use tuple with TestCasesSource in NUnit?

I've been writing some tests in C# using NUnit unitl I encountered an issue with test where I'd like to pass 2 times a 3 Item Tuples as an argument to the test. Seems like a similar problem as described here: How can I use tuples in nunit TestCases?…
1
vote
2 answers

Why is Enumerable.OfType(IEnumerable) doesn't work as expected with ValueTuple?

Behavior So I have a collection of Tuple that looks like this: public List<(ElementRowViewModel Parent, ElementBase Element)> ResultCollection { get; private set; } = new List<(ElementRowViewModel Parent, ElementBase Element)>(); When I try to do…
1
vote
1 answer

Why is it impossible to declare a type alias to an F# struct tuple?

It is impossible to define a type alias to a struct tuple in F#. Only with a workaround, it works. let x = struct (1, 2) > val x : struct (int * int) = struct (1, 2) let y : struct (int * int) = struct (4, 5) // explicit type > val y : struct (int…
citykid
  • 9,916
  • 10
  • 55
  • 91
1
vote
1 answer

Can't load System.ValueTuple in dynamically compiled code

I want to use Tuple in dynamically compiled code on .net 4.6.1 . Below is a minimum test case. Any help would be appreciated. Thanks! // First, install System.ValueTuple 4.5 package via nuget into test Project. using System; using…
Ben
  • 1,133
  • 1
  • 15
  • 30
1
vote
1 answer

How can I create a generic case-insensitive multi-key dictionary using ValueTuples?

I know that I can define a dictionary with a System.ValueTuple key (based on this answer) as below: var multiKeyDictionary = new Dictionary<(int key1, string key2), object>() { {(1, "test"), new object() } }; However, I want any string values…
Jordan Parker
  • 1,208
  • 1
  • 16
  • 25
1
vote
2 answers

How to assign List values to list ValueTuples?

I have method which return List and I wanna try to populate ValueTuple from another standard list I get error: Cannot implicitly convert type 'System.Collections.Generic.List<(long PaymentId, long TransactionId)>' to…
redux17
  • 665
  • 5
  • 11
  • 30
1
vote
0 answers

Doxygen and C# ValueTuple

I am using Doxygen 1.8.17 to document a C# project and I am trying to document this: /// /// returns the LU factorization of a general m-by-n matrix A as: P*A = L*U. /// /// a matrix m-by-n public…
user2092113
  • 103
  • 1
  • 5
1
vote
2 answers

Using ValueTuple returns Item1,Item2 why?

The next api returns in Postmen and to the client item1,item2 While I am using ValueTuple to change the names (the names not so important, but I can’t return item1,item2) public async Task<(List categoryFilters, string…
Rachel
  • 33
  • 7
1
vote
1 answer

How to check if a list of ValueTuple is type of List in C# 7

How could I check if a list of ValueTuple is type of List, without regarding the type of parameters. It could be : new List<(150, "test")>() new List<("testy", "test", 148)>() new List<(true, "blablabla")>() What I've tried public…
Vincent Ducroquet
  • 864
  • 4
  • 14
  • 24
1
vote
0 answers

unable to return multiple values ..System.ValueTuple related problem

I'm self-learning using a book.. while working on methods the book introduces returning multiple values from a method. I've changed the code accordingly and installed related Microsoft NuGet package for tuples.. When I check the solution explorer, I…
cogut
  • 75
  • 1
  • 6
1
vote
0 answers

Best way of initializing an array of ValueTuple

I have made an extension method for initializing arrays of ValueTuples, and realized that it can be done in two different ways. I can either replace the array elements with new tuples, or change the properties of the existing elements (because…
Theodor Zoulias
  • 34,835
  • 7
  • 69
  • 104
1
vote
0 answers

Can't use a ValueTuple with more than 4 elements as ASP.NET MVC model

I'm trying to use a C# 7 ValueTuple as the model for a partial view. It works fine when I use a 4-tuple: @model System.ValueTuple But if I try to use a 5-tuple: @model System.ValueTuple I…
1
vote
1 answer

ValueTuple in Razor

I using vs2017 with the latest update MVC 5.2.6 with Razor c# 7.3 .Net Framework 4.7.2 I have a situation where I'm trying to pass a tuple from a view to a partial view @{var tuple = (FirstName: "Babe", LastName: "Ruth"); } @Html.Partial("_Name",…
CodeApe
  • 11
  • 1