---
source: https://iinventedlight.com/library/notes/csharp-nullable-reference-types.md
title: "C# nullable reference types: string vs string?"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC BY 4.0 (dotnet/docs); restated in our own words"
attribution: "Summary by iinventedlight (AI-assisted). Sources: Microsoft Learn, Nullable reference types - C#, CC BY 4.0 (dotnet/docs); Microsoft Learn, Nullable reference types, CC BY 4.0 (dotnet/docs)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-05
as_of: 2026-11-05
confidence: medium
untested: "No code was run; only the fetched documentation pages were read."
category: coding-references
topic_area: "csharp: null safety"
tags: csharp, dotnet, nullable, null-safety
sources:
  - id: S1
    title: "Nullable reference types - C#"
    publisher: Microsoft Learn
    url: https://learn.microsoft.com/en-us/dotnet/csharp/nullable-references
    accessed: 2026-11-05
    license: "CC BY 4.0 (dotnet/docs)"
  - id: S2
    title: "Nullable reference types"
    publisher: Microsoft Learn
    url: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-reference-types
    accessed: 2026-11-05
    license: "CC BY 4.0 (dotnet/docs)"
    license: "CC BY 4.0 (dotnet/docs)"
---
# C# nullable reference types

## Short answer
Nullable reference types let you mark which references may be null. In a nullable-aware context the compiler warns when you dereference something that might be null. [S1][S2]

## Points
- The goal is fewer `NullReferenceException`s. [S1]
- `T` vs `T?` are the same .NET type; the difference is static analysis. [S2]
- Enable the feature with `<Nullable>enable</Nullable>` or `#nullable` pragmas. [S1][S2]
- The null-forgiving operator and null warnings are optional language features. [S2]

## Claims
- id: C1
  claim: Nullable references aim to reduce NullReferenceException.
  source: S1
  evidence: "minimize the chance your code throws System.NullReferenceException"
- id: C2
  claim: You can express which references allow null.
  source: S1
  evidence: "express which references are intended to allow null"
- id: C3
  claim: T and T? are the same .NET type at runtime.
  source: S2
  evidence: "a variable of type T? are the same .NET type"
- id: C4
  claim: Null-forgiving and null warnings are optional features.
  source: S2
  evidence: "null-forgiving operator are optional language features"

## Sources
- [S1] Nullable reference types - C#. Microsoft Learn. https://learn.microsoft.com/en-us/dotnet/csharp/nullable-references . License: CC BY 4.0 (dotnet/docs). Accessed 2026-11-05.
- [S2] Nullable reference types. Microsoft Learn. https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-reference-types . License: CC BY 4.0 (dotnet/docs). Accessed 2026-11-05.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

Source notice: .NET documentation © Microsoft. Licensed under Creative Commons Attribution 4.0 International (https://github.com/dotnet/docs/blob/main/LICENSE).
