string-int-string generates exception with ConvertTo...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • js

    #1

    string-int-string generates exception with ConvertTo...

    Hello,

    I have two text boxes accepting ints and displaying their Sum.

    This code works:

    string ans;
    ans = Convert.ToStrin g(Convert.ToInt 32(textBoxX.Tex t) +
    Convert.ToInt32 (textBoxY.Text) );
    labelAnswer.Tex t = ans;



    But this code generates InvalidCastExce ption:

    labelAnswer.Tex t = Convert.ToStrin g( Convert.ToInt32 (textBoxX.Text) +

    Convert.ToInt32 (textBoxY) );



    Why? What's the difference?

    brad.




Working...