Carl Potter

Carl Potter

  • NA
  • 6
  • 30.1k

write to variables to a file which increment

Nov 20 2010 10:46 AM
I would like to write two variables to a file from two for loops like writing a two dimensional array to file. so if I have a two dimension array 3 by 3 then if I was two write it to a file then it would look somethiing like this.

1,1
1,2
1,3
2,1
2,2
2,3
3,1
3,2
3,3


I have got the code below working sort of right I just need to combine the results of both loop into one writer.WriteLine nothing I try seems to work.
           
            string filePath = @"C:\\seating plan one.txt";

            using (StreamWriter writer = new StreamWriter(filePath, true))

            for (int i = 0; i < 100; i++)
            {
                writer.WriteLine("i = " + i);

                for (int j = 0; j < 10; j++)
                {
                    writer.WriteLine("j = " + j);
                }
            }

so results from i and j together writer.WriteLine(i,  j);
I have tried lots of different file.* but not seems to resolve problem. Can any one help thanks in advance.
          

Answers (3)