B
Bruce D
I'm new to C# .NET and I'm trying to figure out this line of code and why I
get an error for this section of code....
**************
int ShipQty = 0;
foreach(DataRow row in table.Rows)
{
ShipQty += Int32.Parse(row["orderqty"].ToString());
}
**************
....and I get the same error in this section of code too!
**************
foreach(DataRow row in table.Rows)
{
row["extprice"] = Single.Parse(row["orderqty"].ToString()) *
Single.Parse(row["unitprice"].ToString());
}
**************
both of these..."orderqty" and "unitprice" are decimal fields in a table.
The error is an unhandled exception...blah blah...input string was not in
correct format...blah blah.
I think I need to check for the value != null or empty before I use Parse.
I'm not sure how to do that.
My question is why do I get an error or better yet...how do I multiply two
decimal values. I'd like to read up on Single.Parse if someone can send me
to a good online resource. Should I be looking into the Multiply function?
I tried using the Convert.ToInt32 instead of the Int32.Parse but that didn't
work either.
Any advice is greatly appreciated!
-bruce duncan
get an error for this section of code....
**************
int ShipQty = 0;
foreach(DataRow row in table.Rows)
{
ShipQty += Int32.Parse(row["orderqty"].ToString());
}
**************
....and I get the same error in this section of code too!
**************
foreach(DataRow row in table.Rows)
{
row["extprice"] = Single.Parse(row["orderqty"].ToString()) *
Single.Parse(row["unitprice"].ToString());
}
**************
both of these..."orderqty" and "unitprice" are decimal fields in a table.
The error is an unhandled exception...blah blah...input string was not in
correct format...blah blah.
I think I need to check for the value != null or empty before I use Parse.
I'm not sure how to do that.
My question is why do I get an error or better yet...how do I multiply two
decimal values. I'd like to read up on Single.Parse if someone can send me
to a good online resource. Should I be looking into the Multiply function?
I tried using the Convert.ToInt32 instead of the Int32.Parse but that didn't
work either.
Any advice is greatly appreciated!
-bruce duncan