DataRow and Int.Parse
Say you populate a DataSet via OLE, and then create a DataTable
DataTable dtSomeTable = dsSet.Tables["tblSomeTable"];
and then you get a row
DataRow drFirstRow = dtCorporateDetails.Rows[0];
and then you are trying to extract an integer out of the row
int someint = int.Parse(drFirstRow["somedata"].ToString());
Is this the best way to get an integer? Is there a way to test that the drFirstRow["somedata"] contains a valid integer without using a try {} and catch {} block?
Kirtan PatelPosted Aug 6, 2009, 9:50 AM
You Can Use TryParse its better To Use Then Using Int.Parse because it can cause Exception when TryParse Does not
You can Also Use Custom Coded Function Like Below to Check Weather isNumber or Not