行:mdv = new MapDesignerView();
创建一个无限的实例化(无限循环)。请参见下面的代码:
public partial class MapDesignerView : Form
{
public MapDesignerView mdv;
public Map map;
public MapController mapController;
public MapConstructor mapConstructor;
MouseEventHandler detectMouse;
public MapDesignerView()
{
mdv = new MapDesignerView();
map = new Map(mdv);
mapController = new MapController(map);
mapConstructor = new MapConstructor(mapController);
detectMouse = new MouseEventHandler(mapController);
InitializeComponent();
}
}
如您所见,我需要在MapDesignerView
类中创建类的实例mapDesignView
,以传递给另一个类构造函数。如何以不同的方式将此表单传递给 Map 构造函数,使其不会无休止地实例化?