Stats

237 Contributors: 14 Friday, April 7, 2017
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

nameof Operator

Introduction

The nameof operator allows you to get the name of a variable, type or member in string form without hard-coding it as a literal.

The operation is evaluated at compile-time, which means that you can rename a referenced identifier, using an IDE's rename feature, and the name string will update with it.

Syntax

  • nameof(expression)

Related Examples