Richard Smith

Richard Smith

  • NA
  • 3
  • 8.9k

How do I fix :Cannot convert null to double?

Feb 11 2020 12:46 PM
 hello,
 
Do I am reading an Excel spredsheet and puting the data into arrays like so:
string col1[] = new string[rowCount]; //This is fine
double col2[] = new double[rowCount];
for(int i -= 1, i <= rowCount - 1 ; i++)
{
   col1[i] = myWorkBook.Cells[i + 1, 1].Value;
   col2[i] = myWorkBook.Cells[i + 1, 2].Value; //Throws Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Cannot convert null to 'double' because it is a non-nullable value type
 
I tried doing my array as Nullable but that an 8.0 feature and still in 7.3 and cannot upgrade is there a fix to this?
 
Thanks

Answers (2)