In .NET 5, use the null conditional operator
?., as shown below:In the above example,
std?.FirstName is like if(std != null) std.FirstName. The std?.FirstName checks if std is not null then only access the FirstName property.
C# C# 1001 notes @csharp_1001_notes · 6.66K subscribers ?., as shown below:std?.FirstName is like if(std != null) std.FirstName. The std?.FirstName checks if std is not null then only access the FirstName property.