c# - How can fix System.StackOverflow Exception? -
c# - How can fix System.StackOverflow Exception? -
i used 2 classes, , need send/receive methods , variables. when create instance of class gives me system.stackoverflowexception
.
how can prepare problem?
this code:
class setup1 { setup2 set2 = new setup(); int = 5; public int mymethod(); { set2.b = + 10; homecoming set2.b; } } class setup2 { setup1 set1 = new setup(); public int b = 0; void show() { messagebox.show(set1.mymethod()); } }
you have infinite recursion.
in constructor of setup2()
phone call constructor of setup1()
. there phone call constructor of setup2()
and on, infinitely. memory runs out, , stack overflows.
c# class exception
Comments
Post a Comment