When I implement an event in Visual Studio, Resharper is kind enough to offer to create an event invocator for me. I usually did this by hand in the past, and my invocators always looked like this
private void InvokePropertyChanged(PropertyChangedEventArgs e)
{
if (PropertyChanged != null)
{
PropertyChanged(this, e);
}
}
but the invocator created by Resharper looks like this (cleaned up a little by hand)
private void InvokePropertyChanged(PropertyChangedEventArgs e)
{
PropertyChangedEventHandler changed = PropertyChanged;
if (changed != null)
{
changed(this, e);
}
}
Do the people at jetbrains know something about c# I don't? Is there some technical advantage to having the local variable, or is it just an artifact of them having to auto-generate the code?