作者heyshi (ishyeh)
看板C_Sharp
标题[问题] fread & BinaryReader
时间Thu Jul 31 15:18:42 2008
请问大家我这有个 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)
1F:推 toki:System.IO.FileStream.Read() 07/31 17:10
2F:推 proach:可以直接Read( data, offset, length)啊 08/01 16:55