Hi.
I'm using Visual Studio 2015 Community to write the following simple codes in C# (windows form):
int myNumber = 25;
txtTextBox1.Text = myNumber;
I would get a syntax error as follow: "Cannot implicitly convert type int to string."
I understand why I was getting the above error because I didn't have the ToString() method at the end.
But if I rewrote the second line as follow, I did not get a syntax error:
txtTextBox1.Text = txtTextBox1.Text + myNumber;
The number 25 in the textbox just fine.
All I did was I added the second "txtTextBox1.Text" (highlighted in red above). But how come I didn't have to use ToString() at the end?
Thanks,
I'm using Visual Studio 2015 Community to write the following simple codes in C# (windows form):
int myNumber = 25;
txtTextBox1.Text = myNumber;
I would get a syntax error as follow: "Cannot implicitly convert type int to string."
I understand why I was getting the above error because I didn't have the ToString() method at the end.
But if I rewrote the second line as follow, I did not get a syntax error:
txtTextBox1.Text = txtTextBox1.Text + myNumber;
The number 25 in the textbox just fine.
All I did was I added the second "txtTextBox1.Text" (highlighted in red above). But how come I didn't have to use ToString() at the end?
Thanks,