I’ve got an delegate and event with an out parameter:
public delegate void ExampleDelegate(object sender, EventArgs e, out string value);
public event ExampleDelegate Example;
When I’m trying to handle the event:
mg.Example += (sender, e, val) =>
{
//do stuff
};
I’m getting the error Parameter 3 must be declared with the ‘out’ keyword
When I’m throwing in the suggested out keyword like so:
mg.Example += (sender, e, out val) =>
{
//do stuff
};
I’m getting and extra error the type of namespace name ‘val’ could not be found..etc
What am I doing wrong?
Your event handler doesn’t confirm to the .net guidelines.
If you must use it like that, use a delegate, not an event.
You would run into trouble if you had two event handlers modifying your out parameter.
Refer: Events Tutorial
zmbq has already given you the answer to how to correct your error.
I am adding this just for completeness.