Heram Sharma Heram Sharma - 6 months ago 35
C# Question

auto round value by decimal datatype in C# programming

I have problem with one variable that i have declared with decimal datatype and it need to be with decimal datatype i don't wanna change that datatype because i need it on another part as well.

What exactly i need

I am getting 2.12 as discount value. that i have assign to one variable dynamically.

//I am getting 2.12 here
decimal discount = Convert.ToDecimal(label.text); //it convert to 3 (round figure)


Try specifying a culture.

decimal discount = Convert.ToDecimal(label.text, CultureInfo.InvariantCulture);