What does question mark and dot operator ?. mean in C# 6.0?

It’s the null conditional operator. It basically means: “Evaluate the first operand; if that’s null, stop, with a result of null. Otherwise, evaluate the second operand (as a member access of the first operand).” In your example, the point is that if a is null, then a?.PropertyOfA will evaluate to null rather than throwing an exception – it will then compare that null reference with foo (using string’s == overload), … Read more

What is the purpose of nameof?

What about cases where you want to reuse the name of a property, for example when throwing exception based on a property name, or handling a PropertyChanged event. There are numerous cases where you would want to have the name of the property. Take this example: In the first case, renaming SomeProperty will cause a compilation error if you … Read more