There are already a couple of questions similar to this one: this and this
In particular I quote Marc Gravell's answer (here):
If you have A publishing an event, and B subscribing to an event (the handler), then it is only a problem not to unsubscribe if A is going to live a lot longer than B.
But I could not find any mention to the special case when the event source and the handler are the same reference, for example:
class Foo
{
public event Action SomeEvent;
public Foo() => SomeEvent += OnSomeEventHappened; //should I unsubscribe somewhere?
private void OnSomeEventHappened(){}
}
I just want to be sure there is no hidden issue with the above code. As far as I know I may never unsubscribe from that event since both the subscriber and the publisher are exactly the same instance.
Would not subscribing prevent my Foo instance from being garbage collected?