提问人:Honza 提问时间:1/5/2023 最后编辑:M. JustinHonza 更新时间:11/6/2023 访问量:82
char 等于 “,”有什么问题?[关闭]
What is the problem with char equal to ","? [closed]
问:
string odp = "2,1";
bool abs = odp[1].Equals(",");
当我这样做时,它显示符号,那么为什么它等于 false?Console.Writeline(odp[i])
","
我尝试改用,但它也不起作用。提前致谢==
答:
1赞
Rob Kite
1/5/2023
#1
A 在 C# 中封装在单引号中(a 使用双引号)。Char
','
String
","
请尝试以下操作:
string odp = "2,1";
bool abs = odp[1].Equals(','); // true
评论
0赞
Dmitry Bychenko
1/6/2023
...或bool abs = odp[1] == ',';
评论
char
String
","
','