Reputation: 43873
Having some issue with this...
if (System.Convert.ToInt32(TotalCost(theOrder.OrderData.ToString()).ToString()) < 10000)
ViewData["cc"] = "OK";
else
ViewData["cc"] = "NO";
yields: "Input string was not in a correct format."
How can I check if the number inside the string is less than 10000?
Oh yeah: TotalCost returns a ContentResult of type text/plain
Upvotes: 0
Views: 667
Reputation: 24177
int value = Convert.ToInt32(TotalCost(theOrder.OrderData.ToString()));
if (value < 10000)
{
// ...
}
Upvotes: 0
Reputation: 233487
First use Int32.TryParse to see if the string is a number that falls into the range of Int32.
If the result is a number, you can always compare it to whatever limit you have.
int i;
if (int.TryParse(theOrder.OrderData, out i))
{
if (i < 10000)
{
// Do stuff...
}
}
Upvotes: 4