[英]Compare two strings in two different ways
I've wrote this small program in C# 我已经用C#编写了这个小程序
private void Form1_Load(object sender, EventArgs e)
{
MessageBox.Show(("7797302D875A8922EBFC7DECBD352FE88F35642F" == "7797302D875A8922EBFC7DECBD352FE88F35642F").ToString());
var a = "7797302D875A8922EBFC7DECBD352FE88F35642F";
var b = "7797302D875A8922EBFC7DECBD352FE88F35642F";
MessageBox.Show((a == b).ToString());
}
First messageBox shows "False" while Messagebox shows "True". 第一个messageBox显示为“ False”,而Messagebox显示为“ True”。
My question is: why can I not compare the two strings with the ==
operator? 我的问题是:为什么不能将两个字符串与
==
运算符进行比较?
The difference isn't caused by the comparison, but your test string strings. 差异不是由比较引起的,而是您的测试字符串字符串。
The second string of the first case starts with the invisible 0x200E, the unicode left-to-right mark . 第一种情况的第二个字符串以不可见的0x200E开头,即Unicode 左右标记 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.