CKTIS / C#
nameof: practical reference
nameof: practical reference: nameof produces a symbol's name as a compile-time string without evaluating the symbol.
Version: C# operator reference; verified against C# 14
Syntax
nameof(expression)nameof produces a symbol's name as a compile-time string without evaluating the symbol.
Use it for parameter names, member-name logging, and refactoring-safe metadata.
The result is only the final name component, not a fully qualified name.
Aliases and explicit interface members can yield text different from an expected runtime name.
The complete program actually uses nameof; its exact expected stdout is total.
Examples
using System;
using System.Linq;
using System.Threading.Tasks;
var total = 1; Console.WriteLine(nameof(total));
Result
total
The complete program actually uses `nameof`; its exact expected stdout is `total`.