public class A { string PropertyOfA { get; set; } } A myA = null; var foo = "bar"; string bar = (a == null ? null : a.PropertyOfA); // both the same if (a?.PropertyOfA != foo || bar != foo) { // do something }