Exemple #1
0
        public void Anword(string txt, int m = 1, int n = 10, string output = "output.txt")
        {
            GetDic       cl   = new countletter();
            var          word = cl.CountLetter(txt, m);
            StreamWriter sw   = new StreamWriter(output);

            try
            {
                Console.SetOut(sw);
                CountChar  c    = new countchar();
                CountWords cw   = new countwords();
                CountLines cls  = new countlines();
                SortWord   sort = new sortwords();
                Console.WriteLine("characters: {0}", c.countChar(txt));
                Console.WriteLine("lines: {0}", cls.countLines(txt));
                Console.WriteLine("words: {0}", cw.coutWords(word));
                sort.sortWord(txt, m, n, output = "output.txt");
            }
            catch (Exception e)
            {
                Console.WriteLine("输出文件错误!");
            }
            finally
            {
                sw.Flush();
                sw.Close();
            }
        }