What is this char? 65279 ''

I have two lines.

one is "\" "

and the other is "\" "

I think they are the same.

However, String.Compare says they are different.

It is very strange.

Here is my code.

string b = "\""; string c = "\""; if (string.Compare(b, c) == 0) { Console.WriteLine("Good"); } if (c.StartsWith("\"")) { Console.WriteLine("C"); } if (b.StartsWith("\"")) { Console.WriteLine("B"); } 

I expected him to print "GoodCB."

However, it only prints “B”.

In my debugger, c [0] is 65279 ”, and c [1] is 34”, and b [0] is “”.

But I do not know what 65279 is. ''

Is there an empty character?

Thank.

+30
c # char
Jul 22 2018-11-11T00:
source share
3 answers

This is a zero width without a space .
It is more often used as a byte byte (BOM) .

+46
Jul 22 2018-11-11T00:
source share

If you are reading from a file that you opened in notepad, he may have added it, as this is one of several programs known for this.

+3
Jul 22 2018-11-11T00:
source share

If you use Notepad ++, try converting to UTF-8 (without specification), and also make sure ALL your files in the project have the same file system format.

+2
Nov 23 '15 at 21:01
source share



All Articles