Your code is incorrect. You have a method inside another method, which is not allowed. Therefore the compiler states it expects a }
, before the public void Ergebnis()
.
Your code if you write it out is
1. using System;
2. using System.Windows.Forms;
3. namespace RunTimeCompiler {
4. public class Test {
5. public static void Main() {
6. public void Ergebnis() {
7. MessageBox.Show((1 + 2 + 3).ToString());
8. }
9. }
10.}
11.}
12.}
Note that on line 6 you need to close the method scope for Main before declaring your next method. A correct program would be
using System;
using System.Windows.Forms;
namespace RunTimeCompiler {
public class Test {
public static void Main() {
new Test().Ergebnis();
}
public void Ergebnis() {
MessageBox.Show((1 + 2 + 3).ToString());
}
}
}