Answer the question
In order to leave comments, you need to log in
How to add numbers C#?
There is a text in label10 equal to 0.
I wrote such a code that should add 1 as many times as there are lines in textbox2.
But he does not add, but adds instead of 5 it turns out 011111
int lineCount = textBox2.Lines.Length;
string one = "1";
for (int line = 0; line < lineCount; line++)
{
label10.Text = label10.Text + one;
}
Answer the question
In order to leave comments, you need to log in
I'm in a sisharp with a foot in the tooth, so I may not understand something. But you have explicit string concatenation. Convert values to numbers.
I’m doing an example blindly, I repeat, I’m not familiar with the language, I took the first type conversion manual that came across. I may be wrong somewhere:
int lineCount = textBox2.Lines.Length;
for (int line = 0; line < lineCount; line++)
{
label10.Text = (Convert.ToInt32(label10.Text)++).ToString();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question