Retrieving values from DataTable
-
Hi, Sorry for my ignorance... I need to retrieve values (decimals) from a DataTable. What is the difference between these two methods of converting the object to a decimal and which one is best? Is there another way of retrieving decimals and keeping their native format? A: decimal labelWidth = Convert.ToDecimal(myDataTable.Rows[0]["LabelWidth"]); B: decimal labelWidth = (Decimal)myDataTable.Rows[0]["LabelWidth"]; Ron
-
Hi, Sorry for my ignorance... I need to retrieve values (decimals) from a DataTable. What is the difference between these two methods of converting the object to a decimal and which one is best? Is there another way of retrieving decimals and keeping their native format? A: decimal labelWidth = Convert.ToDecimal(myDataTable.Rows[0]["LabelWidth"]); B: decimal labelWidth = (Decimal)myDataTable.Rows[0]["LabelWidth"]; Ron
(a) They are both the same and (b) If you make labelWidth an object then you don't need to do a conversion to decimal at that time. object labelWidth = myDataTable.Rows[0]["LabelWidth"]; Never apologise for your ignorance - we all have it :)
Glen Harvy
-
(a) They are both the same and (b) If you make labelWidth an object then you don't need to do a conversion to decimal at that time. object labelWidth = myDataTable.Rows[0]["LabelWidth"]; Never apologise for your ignorance - we all have it :)
Glen Harvy
Thanks Glen! Ron