The below code will take care of casting exception, but you will have to make sure that the table has valid numbers
double[,] f = new double[10000, 10000];
foreach (DataColumn dc in dt.Columns)
{
h = h + 1;
for (int i = 0; i <= 1500; i++)
{
string value = dt.Rows[i][dc] + "";
double d = 0;
double.TryParse(value, out d);
f[h, i] = d;
}
}