The Null-Conditional Index C# with Example



The Null-Conditional Index C# with Example

Similarly to the ?. operator, the null-conditional index operator checks for null values when indexing into a 
collection that may be null. 
string item = collection?[index]; 
is syntactic sugar for 
string item = null; 
 

if(collection != null) 
{ 
item = collection[index]; 
} 

0 Comment's

Comment Form

Submit Comment