1

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 can see that System.ValueTuple there and active.. But my project is not running accordingly as if I'd not installed the tuple package..

else if (division.IsChecked.HasValue && division.IsChecked.Value)
{
        int division, reminder;
        (division, reminder) = Divide(leftHandSide, rightHandSide);
                    result.Text = $" reminder ";
 }

....



        private (int, int) Divide(int leftHandSide, int rightHandSide)
        {
            expression.Text = $" / ";
            int division = leftHandSide / rightHandSide;
            int reminder = leftHandSide % rightHandSide;
            return (division, reminder);
        }



        private void showResult(int answer) => result.Text = answer.ToString();

    }
}
Sir Rufo
  • 18,395
  • 2
  • 39
  • 73
cogut
  • 75
  • 1
  • 6
  • 1
    "But my project is not running accordingly " Could you elaborate ? Does it throw an error ? or is something else? – Anu Viswan Sep 23 '19 at 11:28
  • What behavior are you expecting and which behavior is occuring? – Ackdari Sep 23 '19 at 11:30
  • Version of .NET Framework, Visual Studio, and C#? – Theodor Zoulias Sep 23 '19 at 11:35
  • Severity Code Description Project File Line Suppression State Error CS8179 Predefined type 'System.ValueTuple`2' is not defined or imported Methods E:\000_COGUT_visual\02_C# Kitap Kodları\02_Microsoft Press VS C# Step by Step\Chapter 3\Methods\Methods\MainPage.xaml.cs 84 Active – cogut Sep 23 '19 at 11:37
  • Sir Rufo this come on the line that I define the Divide method.. – cogut Sep 23 '19 at 11:38
  • this is VS 2019.. – cogut Sep 23 '19 at 11:38
  • Have you tried the old way with private Tuple Divide – Peter Marshall Sep 23 '19 at 11:39
  • https://stackoverflow.com/q/38382971/993547 – Patrick Hofman Sep 23 '19 at 11:39
  • Severity Code Description Project File Line Suppression State Error CS8179 Predefined type 'System.ValueTuple`2' is not defined or imported Methods E:\000_COGUT_visual\02_C# Kitap Kodları\02_Microsoft Press VS C# Step by Step\Chapter 3\Methods\Methods\MainPage.xaml.cs 89 Active This is the second error comes with line 89 which is "return (division, reminder);" – cogut Sep 23 '19 at 11:42
  • Can you please provied a [mre] – Ackdari Sep 23 '19 at 11:49

0 Answers0