You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to get the string value of a cell which might contain text or numeric data, or might be blank. However, when I call reader.GetString(i) and the column is blank or contains numeric data, I receive an error, for example:
Unable to cast object of type 'System.Double' to type 'System.String'
Therefore, to get the value as a string, I am needing to write:
If you just want the value converted to some string using the current culture them something like string s = reader.GetValue(i)?.ToString() should work I think.
I am trying to get the string value of a cell which might contain text or numeric data, or might be blank. However, when I call
reader.GetString(i)
and the column is blank or contains numeric data, I receive an error, for example:Therefore, to get the value as a string, I am needing to write:
Is there a better way of doing this?
The text was updated successfully, but these errors were encountered: