Stats

237 Contributors: 14
2017-04-07
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook

nameof Operator

Download c# eBook

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