· Chuck Conway · Programming  · 1 min read

The 5 Different Meanings of the Question Mark in C#

In C# the question mark has 5 meanings as of C# 8.

In C# the question mark has 5 meanings as of C# 8.

In C# the question mark has 5 meanings as of C# 8.

  1. Ternary operators
(true ? "true": "false")

2. Null conditional operator

items?.Count()

3. Nullable types (this should be rebranded as nullable value types)

int?

4. Null-coalescing operator

isnull ?? string.Empty

5. Nullable reference types

string?
Share:
Back to Blog

Related Posts

View All Posts »
C# 8 - Nullable Reference Types

C# 8 - Nullable Reference Types

Microsoft is adding a new feature to C# 8 called Nullable Reference Types. Which at first, is confusing because all reference types are nullable… so how this different? Going forward, if the feature is enabled, references types are non-nullable, unless you explicitly notate them as nullable.

The Collection Comparer, Finding the Differences Between Two Collections

The Collection Comparer, Finding the Differences Between Two Collections

Have you had to compare two collections and execute some logic based on whether the item is in the source collection, in the comparing collection or in both? Yeah, me too, I needed to merge data from the UI and the database. I couldn’t find a good solution, so, I wrote a collection comparer.