how can i execute Method dynamically in roslyn
-
segunda-feira, 12 de dezembro de 2011 16: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
Todas as Respostas
-
segunda-feira, 12 de dezembro de 2011 18: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.
- Sugerido como Resposta Shyam NamboodiripadMicrosoft Employee, Owner segunda-feira, 12 de dezembro de 2011 20:36

