For example, if these codes:
Button button1 = new Button();
// ...
button1.Click -= button1_Clicked;
are executed before:
button1.Click += button1_Clicked;
I found no error or exception, but I am wondering if there is any downside here.
If it is safe, why is it allowed to unsubscribe from an event that has never been subscribed?
List<T>
. If you calllist.Remove(new T())
, it won't throw an exception. At most, you'll get a return value offalse
from most C# collection types.