Looking for c# Answers? Try Ask4KnowledgeBase
Looking for c# Keywords? Try Ask4Keywords

C# Language The Null-Conditional Index


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];