Can I overload the nameof
operator in C#?
The C# programming guide is outdated and the C# 6 under the hood doesn't help me.
How can I overload the nameof
operator?
Can I overload the nameof
operator in C#?
The C# programming guide is outdated and the C# 6 under the hood doesn't help me.
How can I overload the nameof
operator?
The nameof
operator is evaluated at compile-time.
The nameof expression is a constant. In all cases, nameof(...) is evaluated at compile-time to produce a string. Its argument is not evaluated at runtime, and is considered unreachable code (however it does not emit an "unreachable code" warning).
So, these operator cannot be overloaded.