数组是否需要清空,如果需要,什么条件下回清空
// Read the bytes.
while (dataToRead > 0)
{
// Verify that the client is connected.
if (Response.IsClientConnected)
{
// Read the data in buffer.
length = iStream.Read(buffer, 0, 10000);
// Write the data to the current output stream.
Response.OutputStream.Write(buffer, 0, length);
// Flush the data to the HTML output.
Response.Flush();
buffer = new Byte[10000];
dataToRead = dataToRead - length;
}
else
{
// Prevent infinite loop if user disconnects
dataToRead = -1;
}
}
2.
byte[] buffer = new byte[204800];
while (dataToRead > 0)
{
if (HttpContext.Current.Response.IsClientConnected)
{
int length = stream.Read(buffer, 0, Convert.ToInt32(chunkSize));
HttpContext.Current.Response.OutputStream.Write(buffer, 0, length);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Clear();
dataToRead -= length;
}
else
{
dataToRead = -1; //防止client失去连接
}
}
这是大文件下载的代码,2个人写的。一个人在stream.Read(buffer, 0, Convert.ToInt32(chunkSize));后写了buffer = new Byte[10000];数组被重新初始化了,一个没有写,在while循环里直接多次使用,到底该不该清空数组呢?请大神们指教!!!
相关推荐
js删除数组元素、清空数组的简单方法(必看)
一、清空数组 var ary = [1,2,3,4]; ary.splice(0,ary.length);//清空数组 console.log(ary); // 输出 [],空数组,即被清空了 二、删除数组元素 var ary = [1,2,3,4]; ary.splice(0,1); 或 ary.splice($.inArray(2, ary), 1); 其中$.inArray(2, ary)用来查找某元素在数组中的索引位置。 三,js 删除数组几种方法 var arr=[‘a’,’b’,’c’]; 若要删除其中的’b’,有两种方法: 1,delete方法:delete arr[1] 这
javascript 删除数组元素和清空数组的简单方法
javascript 删除数组元素和清空数组的简单方法 一、清空数组 var ary = [1,2,3,4]; ary.splice(0,ary.length);//清空数组 console.log(ary); // 输出 [],空数组,即被清空了 二、删除数组元素 var ary = [1,2,3,4]; ary.splice(0,1); 或 ary.splice($.inArray(2, ary), 1); 其中$.inArray(2, ary)用来查找某元素在数组中的索引位置。 三,js 删除数组几种方法 var arr=[‘a','b','c']; 若要删除其中的’b’,有两
JavaScript中清空数组的方法总结
本文给大家总结了三种js清空数组的方法,每种方法都与众不同,非常不错,具有参考借鉴价值,感兴趣的朋友一起看看吧
将查询条件的input、select清空
查询条件清空将input、select的值清空,下面有个不错的示例,需要的朋友可以了解下
Js 清空数组及注意事项.
js清空数组及注意事项,如果操作不当,会出现意象不到的问题。


