I see a lot of code similar to this in our code base:
void Method()
{
this.someObject.SomeEvent -= someHandler;
this.someObject.SomeEvent += someHandler;
//... other stuff
}
Is this ever useful in any way? I keep giving the implementer the benefit of the doubt, thinking I might have missed something.
I would understand the intention to avoid memory leaks if the code was similar to:
void Method()
{
this.someObject.SomeEvent -= someHandler;
this.someObject = new WhateverClass();
this.someObject.SomeEvent += someHandler;
//... other stuff
}