📅  最后修改于: 2022-03-11 14:49:18.195000             🧑  作者: Mango
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
}