Click here to Skip to main content
15,560,073 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to use a Tuple with 11 values; I seem to be able to set it up but can't read it as it does not compile. The code is as follows.

In frmFoodPantry, the called routine.
C#
// Get the array values
            var intTuple = new Tuple<int, int,="" int="">(intMonth, intDay, intYear);
            var returnArray = new Tuple<bool, bool,="" string,="" tuple="" <int,="" int,="" int="">> (isMonth, isDay, isYear, Month, Day, Year, dateOut, intTuple);
            ////var returnArray = new Tuple<bool, bool,="" string,="" rest,="" tuple<int,="" int,="" int="">>((isMonth, isDay, isYear, Month, Day, Year, dateOut), (intMonth, intDay, intYear));
            ////var returnArray = new Tuple<bool, bool,="" string,="" tuple<int,="" int,="" int="">>(isMonth, isDay, isYear, Month, Day, Year, dateOut, Tuple.Create(intMonth, intDay, intYear));
            // Return the array
            return returnArray;






In frmRegisterInput, the calling routine.
                    Tuple<bool, bool,="" string,="" tuple<="" int,="" int="">>
                        returnParseDate = new Tuple<bool, bool,="" string,="" int,="" int="">
                        (isMonth, isDay, isYear, wsMonth, wsDay, wsYear, strDate ,intShMonth, intShDay, intShYear); 
                    ////returnParseDate = (isMonth, isDay, isYear, wsMonth, wsDay, wsYear, strDate, intShMonth, intShDay, intShYear);
                    returnParseDate = frmFoodPantry.ParseDate(returnDate, "MMM dd yyyy", dtLastDate);
                    isMonth = returnParseDate.Item1;
                    isDay = returnParseDate.Item2;
                    isYear = returnParseDate.Item3;
                    wsMonth = returnParseDate.Item4;
                    wsDay = returnParseDate.Item5;
                    wsYear = returnParseDate.Item6;
                    strDate = returnParseDate.Item7;
                    intShMonth = returnParseDate.Rest.Item1;
                    intShDay = returnParseDate.Rest.Item2;
                    intShYear = returnParseDate.Rest.Item3;


What I have tried:

C#
////var returnArray = new Tuple<bool, bool,="" string,="" rest,="" tuple<int,="" int,="" int="">>((isMonth, isDay, isYear, Month, Day, Year, dateOut), (intMonth, intDay, intYear));
            ////var returnArray = new Tuple<bool, bool,="" string,="" tuple<int,="" int,="" int="">>(isMonth, isDay, isYear, Month, Day, Year, dateOut, Tuple.Create(intMonth, intDay, intYear));


                    ////Tuple<bool, bool,="" string,="" tuple<int,="" int,="" int="">>
                    ////returnParseDate = new Tuple<bool, bool,="" string,="" string,
="" tuple<int,="" int,="" int="">>
                    ////((isMonth, isDay, isYear, wsMonth, wsDay, wsYear, strDate),
                    ////(intShMonth, intShDay, intShYear));
                    ////Tuple<int, int,="" int="">(intShMonth, intShDay, intShYear);

                    Tuple<bool, bool,="" string,="" tuple<="" int,="" int="">>
                        returnParseDate = new Tuple<bool, bool,="" string,="" int,="" int="">
                        (isMonth, isDay, isYear, wsMonth, wsDay, wsYear, strDate ,intShMonth, intShDay, intShYear); 
                    ////returnParseDate = (isMonth, isDay, isYear, wsMonth, wsDay, wsYear, strDate, intShMonth, intShDay, intShYear);
Posted
Updated 10-Sep-22 12:01pm
v2

1 solution

I think Tuples are limited to 8 items.Try using a value tuple. You never instantiate them using new. You simply declare them

C#
(string s, int n) myTuple = (s:"The meaning of life", n: 42);
//You deconstruct them like this
(string s, int n) = myTuple;
Console.WriteLine($"{s} is {n}");

 
Share this answer
 
Comments
PaulaJoannAllen 10-Sep-22 17:07pm    
According to the Microsoft documentation, you can embed one Tuple inside another. I can get s single one working but not when I combine two into one.
George Swan 10-Sep-22 17:39pm    
I think ValueTuples were introduced as a replacement for the Tuple<t> class as that class was found to be less than optimal. As an alternative you could use a structure.
PaulaJoannAllen 10-Sep-22 17:44pm    
I will look into that

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900