看到一段代码:
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#里数组不是不能用变量定义吗?为什么这段代码可以?

解决方案 »

  1.   

    见c#入门经典第88页:
    ...也可以使用非常量的变量来进行初始化,例如:
    int myIntArray=new int[arraySize];
    ...
      

  2.   

    int i;
    byte[] m = new byte[i];
    我试了一下,这样就不行,如果用int i=1就没有错。
    但是
    data = new byte[Convert.ToInt64((pFileStream.Length - cruuent))]里,pFileStream.Length 和current都不是一定的啊,这样用为什么也可以
      

  3.   

    孩子  语言是次要的 还是赶快学asp.net吧 对那个有点了解 出来就有饭吃了 语言 算法学的多好 只是面试时有点用