c# binaryreader之readint32与readint16区别

//检测文件是否存在
            if (File.Exists(file_name))
            {
                Console.WriteLine("文件:{0}已存在"+file_name);
                File.Delete(file_name);
            }

           //向文件写入0至10共11个数字
            FileStream fs = new FileStream(file_name,FileMode.CreateNew);
            BinaryWriter bw = new BinaryWriter(fs);
            for (int i = 0; i < 11; i++)
            {
                //int表示int32,表示32位有符号整数
                //注意是(int)i
                bw.Write((int)i);
            }
            fs.Close();//先关闭内层filestream
            bw.Close();//最后关闭外层binarywriter

            //关闭filestream后变量可以重用
            fs = new FileStream(file_name,FileMode.Open);
            BinaryReader br = new BinaryReader(fs);
            //显示写入文件的11个数字
            for (int i = 0; i < 11; i++)
            {
                try
                {
                //int32相当于我们常见的整数1,2,3,5等数字,要是int16就会变样了或者int64也会变样
                Console.WriteLine(br.ReadInt32());
                }
                catch(EndOfStreamException eof)
                {
                    Console.WriteLine(eof.Message);
                }
            }
            br.Close();
            Console.ReadKey();
请使用浏览器的分享功能分享到微信等