.NET 3.5: anonymous delegate for handlers with ref parameters

I have

public delegate void DocumentCompleteEventHandler(object pDisp, ref object URL)

Can I use a lambda expression like this:

ie.DocumentComplete += (o, e) => {  };

This expression does not work. How do I change it for use in code? Is it possible?

+3
source share
1 answer

You tried:

ie.DocumentComplete += (object o, ref object e) => {};

Sometimes the compiler cannot understand things through pure output, and you need to specify the argument types labmda (and modifiers.). Note that this is all or nothing: you must specify types for all arguments or not in all.

ps I'm waiting for some Mr. Skeet to jump here and put in an essay to steal all my glasses.

+6
source

Source: https://habr.com/ru/post/1766960/


All Articles