c# - Calling a constructor within another constructor using 'this' as an argument -
i have following code
public insight3dplugincontrol(insight3dplugin plugin, mapviewmodel viewmodel) : base(plugin) { initializecomponent(); rxmouse = new rxmapmouse(this); eob_tool = new eobtool(rxmouse); } and i've been trying wrap head around use of 'this' in new rxmapmouse() being called 'this's constructor. i'm trying understand reason doing , design pattern called.
i understand object before being passed rxmapmouse() initialized, mean changing current insight3dplugincontrol object when assign rxmouse field, change 1 inside of rxmapmouse()?
the "this" keyword "variable" representing current object.
maybe ( :d ) let undestand better:
public insight3dplugincontrol(insight3dplugin plugin, mapviewmodel viewmodel) : base(plugin) { initializecomponent(); insight3dplugincontrol thecontrol = this; rxmouse = new rxmapmouse(thecontrol); eob_tool = new eobtool(rxmouse); } so, "rxmapmouse" needs instance of "insight3dplugincontrol" int it's constructor , in line current insight3dplugincontrol code lives being sent.
Comments
Post a Comment