Saturday, 28 September 2013

Best way to pass delegate parameters

Best way to pass delegate parameters

What is the best way to pass parameters through to a delegate? I can see
benefits for both of the following ways so I would like to know the most
used and industry accepted way of doing it:


1) I can pass any parameters individually with each parameters being just
that, a parameter.
Example Delegate
public delegate void MyDelegate(bool PARAM1, String PARAM2, int PARAM3);



2) I can pass any parameters through a struct and the only parameter of
the delegate is that struct.
Example Struct
public struct MyDelegateArgs
{
public bool PARAM1;
public String PARAM2;
public int PARAM3;
}
Example Delegate
public delegate void MyDelegate(MyDelegateArgs args);

No comments:

Post a Comment