Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

C# inline question mark on object

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
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #inline #question #mark #object
ADD COMMENT
Topic
Name
7+9 =