gpt4 book ai didi

具有特殊字符的 C# 变量名

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

我想在 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/

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