Note: this was inspired by WebBrowser Event Properties?
Why am I able to access the MulticastDelegate
members of an event within the type that declares the event but not outside of it?
For instance:
using System;
class Bar
{
public static event Action evt;
}
class Program
{
static event Action foo;
static Bar bar;
static void Main()
{
// this works
Delegate[] first = foo.GetInvocationList();
// This does not compile and generates the following
// error:
//
// The event 'Bar.evt' can only appear on the
// left hand side of += or -= (except when used
// from within the type 'Bar')
Delegate[] second = bar.evt.GetInvocationList();
}
}
I get the feeling this is something very simple that I am not seeing.