这真的混淆了我,说我要一个整数保存到一个文件中,INT X = 56,的BinaryWriter采用ASCII等效56表示在内存 00000000 00000000 00000000 00111000,具体做法是:空空空8,并将其写入文件?我对么?有人可以解释如何将这些twofunction当我应该使用每个人?即时通讯使用C#顺便说一句。 thanx提前!
this really confuses me, say i want to save an integer into a file, int x=56, the binarywriter takes the ascii equivalent of the representation of 56 in memory 00000000 00000000 00000000 00111000 , which would be : null null null 8 and write it to the file? am i correct? can someone explain how those twofunction and when should i use each of them? im using c# btw. thanx in advance!
推荐答案从MSDN页面的的StreamWriter 和的BinaryWriter 你可以清楚地看到差异:
From the MSDN pages for StreamWriter and BinaryWriter you can clearly see the differences:
StreamWriter的:
StreamWriter:
实现为在一个特定的编码写入字符流的的TextWriter
Implements a TextWriter for writing characters to a stream in a particular encoding.
和
的BinaryWriter:
BinaryWriter:
在二至流写入基本类型和支持写入A特定的编码字符串。
Writes primitive types in binary to a stream and supports writing strings in a specific encoding.
第一个写东西的文本,二进制第二写入,小尾数,所以 INT X = 56 将被写入 00111000 00000000 00000000 00000000 。
The first one writes things as text, the second writes in binary, little endian, so int x = 56 would be written 00111000 00000000 00000000 00000000.
更多推荐
什么是的StreamWriter和的BinaryWriter之间的区别?
发布评论