title: How do we programatically add data from datagrid to list?
body: <p>I have the following code, but the list is not fetching the exact values from datagrid.    </p>
  
  <pre><code>public List&lt;double[]&gt; ExtractGridData(DataGridView grid)
      {
          int numCols = grid.Columns.Count;
          List&lt;double[]&gt; list = new List&lt;double[]&gt;();
  
              double[] cellsData = new double[numCols];
              foreach (DataGridViewCell cell in grid.SelectedCells)
              {
                  if (cell.Value != null)
                      cellsData[cell.RowIndex] = Convert.ToDouble(cell.Value);
                      list.Add(cellsData);
              }
  
          return list;
      }
  </code></pre>