我想在 C# 中的 string
变量名中包含一些特殊字符。
示例: string foo-bar = String.Empty;
据我所知,我不能像在上面的例子中提到的那样声明一个变量。 有没有办法声明一个包含“-”的变量名?
最佳答案
来自 MSDN :
You can't just choose any sequence of characters as a variable name. This isn't as worrying as it might sound, however, because you're still left with a very flexible naming system. The basic variable naming rules are as follows:
The first character of a variable name must be either a letter, an underscore character (_), or the at symbol (@). Subsequent characters may be letters, underscore characters, or numbers.
关于具有特殊字符的 C# 变量名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25217167/