I have some questions with the following (very simplified) C# code
class MyFactory{
public static void createMyForm(){
Config c=new Config();
MyControl m = new MyControl();
c.someEvent+=m.somClick;
MyForm f=new MyForm(c);
f.mc=m;
f.addcontrol(f);
f.Show();
}
}
class Config{
some data;
public event someEvent;
}
// Custom control
class MyControl:Control{
}
class MyForm:Form{
private Config config;
public MyControl mc; // I need this here, myControl can be Menu or even Panel
public MyForm(Config c){
config=c;
}
}
Will GC handle and dispose all created objects properly? Should I implement dipose pattern to set myForm.mc to null? What about events and references?