[問題] fread & BinaryReader
請問大家我這有個 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
07/31 17:10, 1F
推
08/01 16:55, , 2F
08/01 16:55, 2F