Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

null check syntax c#

//Check if an object is null before calling a function using the ? operator.
//The ? operator is syntactic suger for the if block below:

//Using the ? operator
myObject?.MyFunc();

//Using an if block.
if (myObject != null)
{
  myObject.MyFunc();
}
 
PREVIOUS NEXT
Tagged: #null #check #syntax
ADD COMMENT
Topic
Name
8+7 =