c# - Is data “lost” when using binary data in a string?

后端 未结 9 1766
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-16 13:58

I\'ve tried reading a JPG file using the StreamReader class\' ReadToEnd() method which returns a string.

For some reason though, when I wri

9条回答
  •  一生所求
    2021-01-16 14:30

    Strings use Unicode encoding by default, unicode uses the NUL character as a control character, double NUL is used for termination, a single NUL is used to represent an ASCII character before it.

    Its for this reason that binary data cannot be loaded into a string.

提交回复
热议问题