Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: AddEventHandller implementation

$
0
0
hi,
i would implement my own AddEventHandler.
my code:
public class Window
    {
        private Form f;
        public Window(Form f)
        {
            this.f = f;
        }

        public void AddEventHandler(string name, dynamic handler)
        {
            f.GetType().GetEvent(name).AddEventHandler(f, Delegate.CreateDelegate(f.GetType(), new Action<string,string>((s, s1) => handler(s, s1)).Method));
        }
    }
but it throws an exception: The type must be inferred from the delegate.
Parameter name: type

Viewing all articles
Browse latest Browse all 2297

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>