gpt4 book ai didi

c# - 是否可以在 C# 中重载 nameof 运算符?

转载 作者:行者123 更新时间:2023-11-30 14:22:55 26 4
gpt4 key购买 nike

我可以在 C# 中重载 nameof 运算符吗?

C# programming guide已经过时并且 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# - 是否可以在 C# 中重载 nameof 运算符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47811561/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com