Hallo,
also ich hoffe ich stelle hier keine dumme Frage, aber wieso habe ich eine NullReferenceException bei diesem Quellcode?
Wie kann man das anders machen?
test.aspx
C#-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9:
| protected void Page_Load(object sender, EventArgs e) { Class1 c = new Class1(); }
public void Paint(int a) { Label1.Text = Convert.ToString(a); } |
Class1.cs
C#-Quelltext
1: 2: 3: 4: 5: 6: 7:
| public class Class1 { public Class1() { Class2 c2 = new Class2(333); } } |
Class2.cs
C#-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
| public class Class2 { int a; public Class2(int a) { this.a = a; startme(); }
public void startme() { test t = new test(); t.Paint(a); } } |
Gruß, Vitalic