how can i execute Method dynamically in roslyn
-
2011년 12월 12일 월요일 오후 4:51
Hi ,
I am using c#.net . i have a project in winforms which contains two form and one usercontrol .
usercontrol contains two button save and cancel.
Both form contain a method called save() and usercontrol.
now i want, when form1 is open , and user click on save button in form1 then save() Method of form1 should fired .
Remember that save button is in usercontrol not in form1. i don't want to use case and if condition in usercontrol.savebutton_click method.
it should execute save() Method of parent form. how can it possible . please send me a sample code for this.
thanks . i am waiting for this.
Prem Shah
모든 응답
-
2011년 12월 12일 월요일 오후 6:44
I'm not sure doing it exactly like this is a good idea. The usercontrol should probably offer a Save event and the form can subscribe to that.
Alternatively, you could implement an interface in both forms that contains the Save() method and call that from the usercontrol.
But if you are sure you want to do it the way you describe, I don't see why or how would you want to use Roslyn. You could either use reflection or dynamic for that instead.
- 답변으로 제안됨 Shyam NamboodiripadMicrosoft Employee, Owner 2011년 12월 12일 월요일 오후 8:36

