string str = "Hello.World!";
        string[] split = str.Split(new Char[] { '.', '!' });
        foreach (string s in split)
        {
            if (s.Trim()!= "")
                Console.WriteLine(s);        }
        Response.Write(str.ToString() + "<br>");运行结果为:Hello.World!虽然没有错误.正确答案应该为 Hello
                         World

解决方案 »

  1.   

      Response.Write(str.ToString() + " <br>"); 你输出的不还是str么?
    string str = "Hello.World!"; 
            string[] split = str.Split(new Char[] { '.', '!' }); 
            foreach (string s in split) 
            { 
                if (s.Trim()!= "") 
                    Response.Write(s+ " <br>");         } 
            //Response.Write(str.ToString() + " <br>"); 
      

  2.   

            string str = "Hello.World!"; 
            string[] split = str.Split('.'); 
            string[] split1 = split[1].Split('!');
            Console.WriteLine(split[0]); Hello
            Console.WriteLine(split1[0]);World