I have a method to do something based on the input parameter. Now, I want to call the method by adding to the invocation list of a delegate but with different parameters.
is it possible to do without invoking the delegate multiple times?
private delegate void myDel(int a);
private myDel del;
public MainWindow()
{
InitializeComponent();
del = delmethod;
}
private void delmethod(int a)
{
//Do something
}
private void call_methods()
{
del(1);
del(2);
del(3);
}
Is this the right way or I have any other options? Please note that , I may want to pass many parameters like this using a loop.
though I referred here, they have solution only for calling different methods but I want for the same method.
EDIT :
I want to transfer data from one
database to another by calling the
method depending on the parameter
Environment : Windows forms, .Net 3.5
Possible but ugly. You end up with something like: