>Can the following be done without an intermediate variable?
>
>As one of the first sample application in class, we made a currency calculator. The command button was to take the numbers from two text boxes, multiply (or divide) them, and place the result into a third text box.
>
>The content of the first two textboxes, of course, had to be converted. IIRC, I did this with the method System.Double.Parse(). I assigned the multiplication to a variable, declared with:
>
>
>Double x;
>
>
>So, the calculation was something like:
>
>
>x = System.Double.Parse(TxtExchangeRate.Text) * System.Double.Parse(TxtAmount.Text)
>
>
>Then I saved x.ToString() to the result, something like this:
>
>
>txtResult.Text = x.ToString()
>
>
>However, we didn't manage to do the same without an intermediate variable. Is this possible?
Hi Hilmar,
Yes possible and at first it seems unbelieveable what you might do similarly:
txtResult.Text =
(Double.Parse(TxtExchangeRate.Text) * Double.Parse(TxtAmount.Text)).ToString();
You could also do this:
123.ToString();
:)
Cetin