{"id":3905,"date":"2014-03-30T06:18:58","date_gmt":"2014-03-30T06:18:58","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/finding-the-delegate-method-registered-to-an-event-collection-of-common-programming-errors\/"},"modified":"2014-03-30T06:18:58","modified_gmt":"2014-03-30T06:18:58","slug":"finding-the-delegate-method-registered-to-an-event-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/finding-the-delegate-method-registered-to-an-event-collection-of-common-programming-errors\/","title":{"rendered":"finding the Delegate Method registered to an Event-Collection of common programming errors"},"content":{"rendered":"<p>A .Net event is simply a pair of methods named <code>add_Whatever<\/code> and <code>remove_Whatever<\/code>. They are not guaranteed to be backed by field.<\/p>\n<p>When you write <code>event EventHandler Whatever;<\/code> in C#, it will automatically generate a private field with the same name as the event, and <code>add<\/code> and <code>remove<\/code> accessors that set the field.<\/p>\n<p>You can inspect these at runtime by using Reflection to get the value of the private field, then callings the public <code>GetInvocationList<\/code> method of the <code>Delegate<\/code> class (without reflection).<\/p>\n<p>For non-simple events, including all WinForms events, this approach will not work.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A .Net event is simply a pair of methods named add_Whatever and remove_Whatever. They are not guaranteed to be backed by field. When you write event EventHandler Whatever; in C#, it will automatically generate a private field with the same name as the event, and add and remove accessors that set the field. You can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3905","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3905","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3905"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3905\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}