Double d=0;
if (! Convert.isdbnull (Datatable.rows[i][m]))
{
String Str=datatable.rows[i][m]. ToString (). Trim ();
if (! String.IsNullOrEmpty (str))//non-empty string
if (Double.tryparse (str,out D))//d is the correct number
d*=0.1;
}
D at this point can be assigned to the other
DBNull:D Bnull is a class, DBNull.Value is its only instance, which refers to the value of NULL (<NULL>) data in the database
null: Represents a null reference that does not reference any object, and does not exist for this field
Convert.isdbnull () can tell if an object is DBNull.Value
Example :
A database table structure is
ID Name Score
1 Hello <null>
Populating the above table data into a DataTable instance of a DataTable in. Net
Remove score Value
datatable.rows[0]["Score"] is the DBNull.Value instance.
asp.net,c# operation database DataTable about NULL NULL judgment