Matthew Smith

Matthew Smith

  • 2.1k
  • 2
  • 1.5k

newbie - getting weird returned value

Dec 1 2015 11:12 PM
I am new to c#, so bear with me.  I have written a recursive function, but I am getting an odd return value.  This is the value I am getting back:
 
System.Collections.Generic.List`1[System.Int32]
 
When it should be something like this:
 
10-14-53-60 
 
Here is the function.  I would appreciate any help.
 
static string CallBack(string TheInputList, int ThePosition)
        {
            try
            { 
                var TheList = TheInputList.Split('-').Select(int.Parse).ToList();
                int IncrementedPositionValue = TheList.ElementAt(ThePosition) + 1;
                TheList[ThePosition] = IncrementedPositionValue;
                if (IncrementedPositionValue == 96)
                {
                    for (int i = 1; i <= ThePosition; i++)
                    {
                        TheList[i] = 1;
                    }
                    int NextPosition = ThePosition + 1;
                    string TheNewList = CallBack(TheList.ToString(), NextPosition);
                    return TheNewList;
                }
                else
                {
                    string TheReturnString = TheList.ToString();
                    return TheReturnString;
                }
            }
            catch {
                TheInputList = TheInputList + "-0";
                string TheList = null;
                TheList = CallBack(TheInputList, ThePosition);
                return TheList;
                
            }

Answers (2)