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
3 answers

Is it possible to automatically map from ValueTuple<> to class properties?

Using some existing Mapper, is it possible to: var target = Mapper.Map(source).To(); where source is IEnumerable<(string Foo, int Bar)> and Dto is class with properties Foo and Bar? Example code: using System; using…
Tomasito
  • 1,864
  • 1
  • 20
  • 43
1
vote
3 answers

Send list of variables one class to other class in python

Here iam want send one class object properties to other class.my basic program look like here class A(): def __init__(self,name,age): Self.name = name Self .age = age Return tuple(self.name,self.age) Class B(): …
shiva gangula
  • 45
  • 1
  • 8
1
vote
2 answers

Error when building System.ValueTuple in .NetStandard 2.0 project

I have a .NetStandard project that uses System.ValueTuple. It builds fine in visual studio whether or not I include the System.ValueTuple nuget package. However it fails either way when I build it on team-city with the error: error CS8137: Cannot…
1
vote
1 answer

C#. Error CS8135: Tuple with 2 elements cannot be converted to type 'object'

Consider the following method: public object Foo(bool flag) { if (flag) return (new object(), new object()); return (null, new object()); //Compiler error over here!! } This does not compile showing the error I mentioned in the…
taquion
  • 2,667
  • 2
  • 18
  • 29
1
vote
1 answer

Use ValueTuple in Ninja Trader 8 C# .Net 4.5

This question is beyond the scope of NinjaTrader Customer Service. The trading platform targets .Net 4.5 and I would like to use ValueTuple (.Net 4.7) with it. I see there is this Nuget Package to add ValueTuple to previous versions of…
Roblogic
  • 107
  • 3
  • 8
1
vote
1 answer

How to hand over a local var to another method in C#?

I have got a deserialization method which returns a ValueTuple: var des = deserializeobject(filename); Now I would like to work with these arrays within the method public static void oDocX(); How…
Anne Martin
  • 69
  • 1
  • 10
1
vote
2 answers

Why does NuGet complain about System.ValueTuple (4.3.1)?

I've just created console F# application for dotnet core 2. VS shows exclamation mark on System.ValueType (4.3.1) package. I know this reference is implicit:
Pavel Voronin
  • 13,503
  • 7
  • 71
  • 137
1
vote
0 answers

Upgrade EFCore: Could not load file or assembly System.ValueTuple, Version=0.0.0.0

I'm trying to upgrade EFCore 1.1 to EFCore 2.1 After a long journey of "Could not load assembly" and a bunch of NuGet updates, I'm facing what I think is the last wall before the accomplishment. Could not load file or assembly 'System.ValueTuple,…
Robouste
  • 3,020
  • 4
  • 33
  • 55
1
vote
1 answer

How to dynamically iterate/detect member types in ValueTuple that has null members?

I'm trying to make use of ValueTuple to concisely enter a list of N types in a generic method's parameter list, and then later iterate that list of types. However, I'm running into a problem when iterating the types, because the initial Tuple has…
Brett Rossier
  • 3,420
  • 3
  • 27
  • 36
1
vote
1 answer

Compilation fails when using System.ValueTuple

VS 2017 version 15.3.2 project targets framework 4.6.2 Installed nuget package System.ValueTuple latest stable 4.4.0 Use value tuple, no error shown in editor Run compile step, no errors in error window, only output window shows compilation…
epitka
  • 17,275
  • 20
  • 88
  • 141
0
votes
2 answers

ValueTuple in Select Linq

Good day, I have a problem, I need to pull out from query several values var val= context.tab1.Select(x=> new {x.a,x.b,x.c}) but variable "val" will have anonymous type and because of that I cant complete my task. My next idea was get variables and…
0
votes
1 answer

Guarantee to return a non-empty tuple (non null fields) in C#

I wrote this code: var (left, right) = A.FooWith(B); where left, right, A and B are all Ts: public class T { // ... public (T left, T right) FooWith(T other) { T left = new (GetInfoFrom(this, other)); T right = new…
WaterFox
  • 850
  • 6
  • 18
0
votes
1 answer

How do I return a range and a fixed value at the same time?

How do I return a range for the arithmetic type and a fixed value for the geometric type at the same time? I know that I can't but is there a workaround? public (double MinimumProfitPerGrid, double MaximumProfitPerGrid) CalculateProfitPerGrid() { …
nop
  • 4,711
  • 6
  • 32
  • 93
0
votes
2 answers

Quick ValueTuple initialization with 1 argument

I want to create a simple way to create a matrix-like structure for users. This means that the user can define rows and columns. For now its looks like this: var matrix = new() { new() { Item1, Item2 } // Row new() { Item3, Item4 } //…
0
votes
2 answers

Number and type of elements in System.ValueTuple

I was looking for an alternative to a local structure in C#, which is possible in C/C++ but not possible in C#. That question introduced me to the lightweight System.ValueTuple type, which appeared in C# 7.0 (.NET 4.7). Say I have two tuples defined…
AlainD
  • 5,413
  • 6
  • 45
  • 99