C# Language The Null-Conditional Index

Download C# Language for free

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