`

c#的二进制 读写

    博客分类:
  • C#
c# 
阅读更多
http://stackoverflow.com/questions/5463476/how-to-read-a-binary-file-using-c

这里有一点点说明

http://www.switchonthecode.com/tutorials/csharp-tutorial-serialize-objects-to-a-file
有序列化的写法

今天在对比二进制写入的时候,发现一个问题
string abc = "aabbcc";
bw.Write(abc);
会无缘无故地在二进制的文件里面出现
06 61 61 62 62 63 63
这个06真是不知道怎么出现的
所以,后来我只好写了一个
      
 static private char[] str2chars(string str, int length)
        {
            char[] res = new char[length];
            //必须容错,否则会提示错误
            if (str.Length > length) { str.CopyTo(0, res, 0, length); }
            else { str.CopyTo(0, res, 0, str.Length); }
            return res;

        }

这样的代码来自己制作一个规定长度的char[];

微软关于datagridview的写法
http://msdn.microsoft.com/zh-cn/library/5s3ce6k8

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics