[問題] fread & BinaryReader

看板C_Sharp作者 (ishyeh)時間17年前 (2008/07/31 15:18), 編輯推噓2(200)
留言2則, 2人參與, 最新討論串1/1
請問大家我這有個 C code 的fread function short data[240]; FILE *ifileid; fread(data,sizeof(short),240,ifileid); 檔案是 bin 檔 所以打算用 在c# binaryreader 來做 在 底下是有找到 ReadInt16() 來讀 short 不過這只能一次讀一個short 請問該如何像fread 可以選擇我要搬多少 short ? 謝謝 public static short[] ReadInt16Array(BinaryReader reader, int count) { short[] result = new short[count]; for(int i=0;i<count,i++) { result[i] = reader.ReadInt16(); } return result; } 目前只找到這方法 請問有更好的嗎 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 163.26.228.10 ※ 編輯: heyshi 來自: 163.26.228.10 (07/31 16:39)

07/31 17:10, , 1F
System.IO.FileStream.Read()
07/31 17:10, 1F

08/01 16:55, , 2F
可以直接Read( data, offset, length)啊
08/01 16:55, 2F
文章代碼(AID): #18aMTJic (C_Sharp)