Re: using string instead of int

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



When your database column has an "int" type, you can easily do something like:

DataRow dr = MyDataSet.Rows[0];
int i = (int)dr["MyIntColumn"];

but this will fail if there are "null"s in that column (the field will then contain a DbNull.Value). In that case use this:

int ?i2 = dr["MyIntColumn"] as int?;

Hans Kesting


mavrick_101 explained :
Just to avoid unneccary Convet.ToInt32, while retrieving from an Int type column in table.



.



Relevant Pages