It is not possible to display the variable in the TextBox after calling the method. What to do?

private void button1_Click(object sender, EventArgs e) { int x = 1; int n = 0; for (x = 0; x < 10; x++) n = Even(x); textBox1.Text = n.ToString; } 

Gives an error on n.ToString

Closed due to the fact that off-topic participants iluxa1810 , EvgeniyZ , Denis Bubnov , aleksandr barakin , 0xdb 22 Dec '18 at 19:45 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - iluxa1810, EvgeniyZ, Denis Bubnov, aleksandr barakin, 0xdb
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • four
    textBox1.Text = n.ToString (); - Artyom Prokudin

1 answer 1

ToString is a method, and uses it as a variable. Correctly: ToString ();

 private void button1_Click(object sender, EventArgs e) { int x = 1; int n = 0; for (x = 0; x < 10; x++) { n = Even(x); textBox1.Text = n.ToString(); } }