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

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -