asp.net 过滤数组中不同词重复出现的次数

 protected void Button4_Click(object sender, EventArgs e)
        {
            var path = @"F:\工作\12-9\9-12\9-11\" + TextBox1.Text.Trim();
            string returnStr = string.Empty;
            FileStream fs = null;
            fs = new FileStream(path, FileMode.Open, FileAccess.Read);
            StreamReader sr = new StreamReader(fs, System.Text.Encoding.UTF8);
            var arr2 = sr.ReadToEnd();
            var arr = arr2.Split('|');
            ArrayList array = new ArrayList();
            for (var i=0;i<arr.Length-1;i++)
            {
                if (array.Contains(arr[i]) == false)
                {
                    array.Add(arr[i]);
                };
            }
            for (var i = 0; i < array.Count; i++)
            {
                Response.Write(array[i] + ":出现次数:" + Getstrcount(arr2, array[i].ToString()) + "<br />");
            } 
        }

 

posted on 2012-09-12 17:57  。!  阅读(295)  评论(0编辑  收藏  举报