我正在处理一些与HTML相关的工作,我想打印(在纸上)这些HTML文件,实际上,文件并不存在,所有内容都保存在一个字符串中,所有文本都是HTML格式的,但我希望打印时已经格式化好了...
例如:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string HTML =
"<html>" +
"<head>" +
" <style type=\"text/css\">" +
" .title {" +
" color: blue;" +
" text-decoration: bold;" +
" text-size: 1em;" +
" }" +
" .author {" +
" color: gray;" +
" }" +
" </style>" +
"</head>" +
"<body>" +
" <p>" +
" <span class=\"title\">{0}</span>" +
" <span class=\"author\">{1}</span>" +
" </p>" +
"</body>" +
"</html>";
// Just a sample of what I whant to do...
// PseudoCode
//Render the HTML code
RenderHTML aa = new RenderHTML(string.Format(HTML, "Alexandre", "Bencz"));
aa.PrintDocumentInPaper();
}
}
}
我发现: http://msdn.microsoft.com/en-us/library/w290k23d.aspx
但是我想知道是否有其他更好的方法来做到这一点?与此相关的是it技术。
@
运算符表示它为字符串字面量,这将允许您避免所有的连接。或者,如果您正在连接数据,请确保使用StringBuilder
。祝你好运! - Maurice Reeves