John Q

John Q

  • NA
  • 12
  • 44.3k

C# Returning multiple values

Jan 24 2014 10:48 AM
I've the following code and it seems to work but how do I make it so that when the recursive is finished, it return more than one variable?  Right now it's only return one value, how do I change the sub below to return more than one value like an integer and a string.  Thanks in advance.

using System;

class Program
{
  static int Recursive(int value, ref int count)
  {
  count++;
  if (value >= 10)
  {
  // throw new Exception("End");
  return value;
  }
  return Recursive(value + 1, ref count);
  }

  static void Main()
  {
  int count = 0;
  int total = Recursive(5, ref count);
  Console.WriteLine(total);
  Console.WriteLine(count);
  }
}

Answers (1)