Given the two methods:
static void M1(Person p)
{
if (p != null)
{
var p1 = p.Name;
}
}
static void M2(Perso
I think it's clearly now,
This is an easy and thread-safe way to check for null before you trigger an event. The reason it’s thread-safe is that the feature evaluates the left-hand side only once, and keeps it in a temporary variable. MSDN
So it is safe to use call
instruction here.
I wrote a blog post about the differences between call
and callvirt
and why C# generate callvirt
Thanks Dan Lyons for the MSDN link.