namespace StringBuilder高效字符串操作
{
class Program
{
static void Main(string[] args)
{
StringBuilder sb = new StringBuilder();
//sb.Insert();向字符串中插入
//sb.Replace();替换字符串
sb.Append("<table border='1' width='400px'>\n");
sb.Append(" <tr>\n");
sb.Append(" <td>John</td><td>男</td><td>18</td>\n");
sb.Append(" </tr>\n");
sb.Append(" <tr>\n");
sb.Append(" <td>Blue</td><td>男</td><td>18</td>\n");
sb.Append(" </tr>\n");
sb.Append(" <tr>\n");
sb.Append(" <td>White</td><td>男</td><td>18</td>\n");
sb.Append(" </tr>\n");
sb.Append(" <tr>\n");
sb.Append(" <td>Black</td><td>男</td><td>18</td>\n");
sb.Append(" </tr>\n");
sb.Append("</table>");
File.WriteAllText(@"C:\Documents and Settings\mlq\桌面\1.html", sb.ToString(), Encoding.Default);
//调用浏览器,对数据进行浏览
Process.Start(@"C:\Documents and Settings\mlq\桌面\1.html");
Console.WriteLine("写入");
//Console.WriteLine(sb.ToString());
Console.Read();
}
}
}
{
class Program
{
static void Main(string[] args)
{
StringBuilder sb = new StringBuilder();
//sb.Insert();向字符串中插入
//sb.Replace();替换字符串
sb.Append("<table border='1' width='400px'>\n");
sb.Append(" <tr>\n");
sb.Append(" <td>John</td><td>男</td><td>18</td>\n");
sb.Append(" </tr>\n");
sb.Append(" <tr>\n");
sb.Append(" <td>Blue</td><td>男</td><td>18</td>\n");
sb.Append(" </tr>\n");
sb.Append(" <tr>\n");
sb.Append(" <td>White</td><td>男</td><td>18</td>\n");
sb.Append(" </tr>\n");
sb.Append(" <tr>\n");
sb.Append(" <td>Black</td><td>男</td><td>18</td>\n");
sb.Append(" </tr>\n");
sb.Append("</table>");
File.WriteAllText(@"C:\Documents and Settings\mlq\桌面\1.html", sb.ToString(), Encoding.Default);
//调用浏览器,对数据进行浏览
Process.Start(@"C:\Documents and Settings\mlq\桌面\1.html");
Console.WriteLine("写入");
//Console.WriteLine(sb.ToString());
Console.Read();
}
}
}