看到一段代码:
byte[] data;
int byteCount = 1 * 1024;for (; cruuent <= pFileStream.Length; cruuent = cruuent + byteCount)
{ if (cruuent + byteCount > pFileStream.Length)
{
data = new byte[Convert.ToInt64((pFileStream.Length - cruuent))];
bReader.Read(data, 0, Convert.ToInt32((pFileStream.Length - cruuent)));
}
else
{
data = new byte[byteCount];
bReader.Read(data, 0, byteCount);
}
reqstream.Write(data, 0, data.Length);
}c#里数组不是不能用变量定义吗?为什么这段代码可以?
byte[] data;
int byteCount = 1 * 1024;for (; cruuent <= pFileStream.Length; cruuent = cruuent + byteCount)
{ if (cruuent + byteCount > pFileStream.Length)
{
data = new byte[Convert.ToInt64((pFileStream.Length - cruuent))];
bReader.Read(data, 0, Convert.ToInt32((pFileStream.Length - cruuent)));
}
else
{
data = new byte[byteCount];
bReader.Read(data, 0, byteCount);
}
reqstream.Write(data, 0, data.Length);
}c#里数组不是不能用变量定义吗?为什么这段代码可以?
解决方案 »
- TCP长连接及网络字节序的疑问
- ASP.NET中用C#怎样实现一个页面停留几秒后再自动跳转其它页面?
- winform如何完整获取数据库表结构,并显示在textbox中?
- winform中如何向Datagride中加Button,分页.打印呢,急!!!!!!!!!
- 有CSharpCode.TextEditor的详细文档么?
- 请教一个问题
- public string test(int sql, string tb, string td){ return ……},如何将这三个值返回调用处?谢谢。
- 请教datagridview绑定多个自定义表
- 原系统是vb,新添子系统可以用c#吗?
- 在webForm 中。有没有datagrid的选定行事件。
- 有用c#做过视频监控方面的人吗?
- 如何安装sql ce
...也可以使用非常量的变量来进行初始化,例如:
int myIntArray=new int[arraySize];
...
byte[] m = new byte[i];
我试了一下,这样就不行,如果用int i=1就没有错。
但是
data = new byte[Convert.ToInt64((pFileStream.Length - cruuent))]里,pFileStream.Length 和current都不是一定的啊,这样用为什么也可以