大量字符串拼接

直接上代码,最后可以网页显示

 class Program
    {
        static void Main(string[] args)
        {

            //内存爆了 
            //string name = "小黑";
            //for(int i = 0; i < 28; i++)
            //{
            //    name += name;
            //}
            //Console.WriteLine("好了");
            //Console.ReadKey();

            StringBuilder sb = new StringBuilder();
            sb.Append("<html>");
            sb.Append("<head><title>这是我的html页面</title></head>");
            sb.Append("<body>");
            sb.Append("<font color=\"red\" size = \"7\" face = \"全新硬笔书简\">锄禾日当午,汗滴禾下土。小赵走过去,炸成二百五。</font>");
            sb.Append("<body>");
            sb.Append("</ html>");

            //转成字符串类型
            string str = sb.ToString();
            File.WriteAllText("1.html", str,Encoding.UTF8);
            Console.WriteLine("你是一首歌");
            Console.ReadKey();

        }
    }

猜你喜欢

转载自blog.csdn.net/nsjlive/article/details/81118055
今日推荐