C# 將long類型寫入二進位檔案用bw.Write((long)num);將其讀出用long num= (long)br.ReadInt64();

來源:互聯網
上載者:User

標籤:寫入   二進位   位元組   符號   binary   檔案的   長整型   有符號   整數   

理由:

因為long類型是 System.Int64 (長整型,占 8 位元組,表示 64 位元整數,範圍大約 -(10 的 19) 次方 到 10 的 19 次方)

而long BinaryReader.ReadInt64()方法是從當前流中讀取八位元組有符號整數,並使流的當前位置向前移動8個位元組。

八位元組對八位元組,所以

講long類型讀取出二進位檔案的方法就是BinaryReader.ReadInt64()

C# 將long類型寫入二進位檔案用bw.Write((long)num);將其讀出用long num= (long)br.ReadInt64();

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.