Skip to content

C# Feature - nameof with unbound generic types

Beginning with C# 14, the argument to nameof can be an unbound generic type such as List<> or Dictionary<,>.

This feature was introduced in C# 14. The official Microsoft Learn page for C# 14 is dated November 18, 2025 and states that C# 14 ships with .NET 10 and Visual Studio 2026.

Before C# 14, nameof worked well for identifiers and closed generic types, but not for unbound generic type forms. That gap was awkward in analyzers, source generation, diagnostics, and reflection-heavy infrastructure code where the generic type definition itself matters.

Console.WriteLine(nameof(List<>)); // List
Console.WriteLine(nameof(Dictionary<,>)); // Dictionary
  • Use it when logging or reporting against a generic type definition rather than a constructed type.
  • Use it in code generation and analyzer scenarios where open generic types are part of the model.
  • Prefer nameof over string literals whenever the name should follow refactoring automatically.
  • nameof(List<>) returns List, not List<>.
  • This feature is about compile-time names, not runtime type inspection.