C# Sudoku

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jollywg
    New Member
    • Mar 2008
    • 158

    C# Sudoku

    I'm writing a sudoku program, that uses textboxes as input. The text box names follow how an array works ie
    (00,01,02,03,04 ,05,06,07,08
    10,11,12,13,14, 15,16,17,18.... )

    Now all i need to do is declare and load the array with those values. I was wondering if there was a way to use a for loop to load the values? Here is what i have so far.

    public class MyClass
    {
    public int[,] LoadTable()
    {
    int[,] table = new int[9,9];
    for (int i = 0; i < 9; i++)
    {
    for (int t = 0; t<9; t++)
    {
    table[i,t] = Convert.ToInt16 (txt[i][t]).Text);
    }
    }
    return table;
    }
    }


    Thanks!
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    You'll have to find the control by it's name, then reference that object?

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by Jollywg
      I'm writing a sudoku program, that uses textboxes as input. The text box names follow how an array works ie
      (00,01,02,03,04 ,05,06,07,08
      10,11,12,13,14, 15,16,17,18.... )

      Now all i need to do is declare and load the array with those values. I was wondering if there was a way to use a for loop to load the values? Here is what i have so far.

      public class MyClass
      {
      public int[,] LoadTable()
      {
      int[,] table = new int[9,9];
      for (int i = 0; i < 9; i++)
      {
      for (int t = 0; t<9; t++)
      {
      table[i,t] = Convert.ToInt16 (txt[i][t]).Text);
      }
      }
      return table;
      }
      }


      Thanks!
      I've just remembered that Jos did a whole series on Sudoku. It's in Java but the languages are closely related and I'm sure you'll find the ideas there very helful for your project.
      Here is the first part.

      Comment

      Working...