title: How to populate a 2d array via user input?
body: <p>I'm trying to create a 5,4 array in C# where each cell is made up of user data. The code I have below works sometimes, but not consistently. I can input data into cell [4,5] or [3,4] for example. However, sometimes when I run the code It does not accept the data and displays an empty cell. and Any tips?</p>
  
  <pre><code>        decimal[,] departments = new decimal[4, 5];
  
          //int count = 0;
          Console.WriteLine("If you would like to run the program, type enter");
          string exit = Console.ReadLine();       
          while (exit != "yes")
          {
              Console.WriteLine("What is the department number that you would like to enter sales for? Enter 9 to exit");
              int departmentNo = int.Parse(Console.ReadLine());
              Console.WriteLine("What day would you like to enter sales for?");
              int input = int.Parse(Console.ReadLine());
  
              Console.WriteLine("Enter sales");
              departments[departmentNo, input] = decimal.Parse(Console.ReadLine());
              Console.WriteLine("If you are finished, enter yes");
              exit = Console.ReadLine();
  
          }
  </code></pre>
  
  <p>Example output </p>
  
  <pre><code>0 0 0 0
  0 0 0 0
  0 0 500 0
  500 0 0 0
  </code></pre>