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 PatelRank #292 · 8.6K reputationPosted Aug 6, 2009, 5:50 AM EDT
You Can Use TryParse its better To Use Then Using Int.Parse because it can cause Exception when TryParse Does not
public bool IsNumeric(string str) { bool isnumber = true; foreach (char c in str.ToCharArray()) { if (Char.IsNumber(c) == false) { isnumber = false; break; } } return isnumber; } Happy coding :)