日期:2014-05-17  浏览次数:21035 次

array.clear不用可以吗?
先贴段代码如下:
C# code

while (ConSvrStatus)
            {

                if (System.IO.File.Exists(@"\ResidentFlash2\RMU900_UHF(new)\\markSavefd.txt"))
                {
                    StreamReader sr = new StreamReader(@"\ResidentFlash2\RMU900_UHF(new)\\markSavefd.txt");
                    System.IO.FileInfo fi = new System.IO.FileInfo(@"\ResidentFlash2\RMU900_UHF(new)\\markSavefd.txt");
                    int ct = 0;
                    while (sr.Peek() >= 0)
                    {
                        string str1 = sr.ReadLine();
                        string[] str2 = str1.Split(new char[] { '-', ' ', '.', ':' });
                        string a1 = str2[0];
                        string a2 = str2[1];
                        string a3 = str2[2];
                        string a4 = str2[3];
                        string a5 = str2[4];
                        string a6 = str2[5];
                        string a7 = str2[6];
                        string a8 = str2[7];
                        string a9 = str2[8];
                        string a10 = str2[9];
                        string a11 = str2[10];
                        string d = str2[0] + str2[1] + str2[2] + str2[3]+str2[4]+str2[5]+str2[6]+str2[7]+str2[8]+str2[9]+str2[10];

                        byte[] byteArray = Encoding.Default.GetBytes("FE" + d.ToString() + d.Length + "FD");
                        Client.Send(byteArray);
                        Array.Clear(byteArray, 0, byteArray.Length);//此处的array.clear可以不用吗?每次执行循环,数组不是重新被赋值了吗,干嘛还要用个清零的动作呢?
                        ct++;                        
                    }
                    sr.Close();
                    string records = Convert.ToString(ct);
                    txtSendData.Text = "records saves ok";
                    fi.Delete();
                }



------解决方案--------------------
初始值有含义呗。。。
------解决方案--------------------
释放那一点点内存么?每次都是新声明了一个数组,用完给释放了