lundi 28 décembre 2015

?? null-coalescing operator vs if == null

When instantiating null objects with ?? null-coalescing operator is there any performance difference, additional cycles, etc. vs simple if == null statement? Any effect from assigning object to itself?

RedColorBrush = RedColorBrush ?? new SolidColorBrush(renderTarget, Color.Red);

vs

if (RedColorBrush == null)
{
    RedColorBrush = new SolidColorBrush(renderTarget, Color.Red);
}

Aucun commentaire:

Enregistrer un commentaire