Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# null conditional operator if statement

// This is used if the source of a value is uncertain to exist

// For both of these examples, if 'p' is null, 'name' and 'age' will be null
// (as opposed to throwing an error)
string name = p?.FirstName;
string age = p?.Age;

string silver = preciousMetals?[4]?.Name;
Source by www.informit.com #
 
PREVIOUS NEXT
Tagged: #null #conditional #operator #statement
ADD COMMENT
Topic
Name
9+7 =