AlexC
AlexC

Reputation: 9661

C#, Data Type operations

I'm sorry, a know that it is not sow serious ....

i want to do some operation in C#, How I can do this one ?

decimal resultTK = (42 - Convert.ToDecimal(RouteA.Text)) * 21.25 ;
lblResultA.Text = Convert.ToString(resultTK);

I have some error in Data Type !

Thanks!

Upvotes: 0

Views: 107

Answers (1)

Mitch Wheat
Mitch Wheat

Reputation: 300499

You are trying to implicitly convert between decimal and double. Try:

decimal resultTK = (42 - Convert.ToDecimal(RouteA.Text)) * 21.25M; 

(the M on the constant specifies that it is a decimal)

Upvotes: 3

Related Questions