I want to store result of total & tempDiscRs into b1..while storing it throws the error that Input string was not in correct format
decimal b1 = Convert.ToDecimal(lblDisRate.Text);
b1 = total * tempDiscRs;
You should be aware of the culture you're in.
Example: In US, the comma separator is a dot (.) while in Germany it is a comma (,).
Try
lblDisRate.Text.ToString(System.Globalization.CultureInfo.InvariantCulture)
In order to use Invariant Culture so you always use a dot instead of a comma.
decimal myValue;
if(Decimal.TryParse(lblDisRate.Text, out myValue))
{
//correct
}
else
{
//wrong
}
See more about Decimal.TryParse Method
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.