How do I use a C# reserved keyword as a property name without the @ prefix?

☆樱花仙子☆ 提交于 2019-11-29 14:05:42

You can't. It is a reserved keyword. That means "you can't". Contrast to "contextual keywords" which usually means "we added this later, so we needed it to work in some pre-existing scenarios".

The moderate answer here is: use @return.

A better answer here is: rename your property. Perhaps ReturnValue.

There is also the option of, say, Return - but you might need to think about case-insensitive languages too.

You can rename namespaces like this:

using Test = System.Diagnostics;

No way to achieve this because reserved Keywords are predefined, reserved identifiers that have special meanings to the compiler.

it's better you change name of property and use it in you code...something as given in @Marc answer...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!