是否可以在 C# 中重载 nameof 运算符?
Is it possible to overload the nameof operator in c#?
我可以在 C# 中重载 nameof
运算符吗?
C# programming guide is outdated and the C# 6 under the hood 对我没有帮助。
如何重载 nameof
运算符?
nameof
运算符在编译时求值。
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).
因此,不能重载这些运算符。
我可以在 C# 中重载 nameof
运算符吗?
C# programming guide is outdated and the C# 6 under the hood 对我没有帮助。
如何重载 nameof
运算符?
nameof
运算符在编译时求值。
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).
因此,不能重载这些运算符。