我有 HTML 中的基本代码,我想将此代码转换为字符串格式。
<table id="rounded-corner" summary="2007 Major IT Companies' Profit" style="text-align: center">
<thead>
<tr>
<th scope="col" class="rounded-company"></th>
<th scope="col" class="rounded">Název</th>
<th scope="col" class="rounded">Web</th>
<th scope="col" class="rounded">Popis</th>
<th scope="col" class="rounded">Edit</th>
<th scope="col" class="rounded-q4">Delete</th>
</tr>
</thead>
<tbody>
我希望这个 HTML 用于 string.Format。
StringBuilder data = new StringBuilder();
data.Append(string.Format(@"<table id="rounded-corner" summary="2007 Major IT Companies' Profit" style="text-align: center">
<thead>
<tr>
<th scope="col" class="rounded-company"></th>
<th scope="col" class="rounded">Název</th>
<th scope="col" class="rounded">Web</th>
<th scope="col" class="rounded">Popis</th>
<th scope="col" class="rounded">Edit</th>
<th scope="col" class="rounded-q4">Delete</th>
</tr>
</thead>
<tbody>"));
我对 string.Format 的这个符号 ""有疑问,你能帮我看看我该怎么做吗?
你需要像这样放置\"
:
string.Format(@"<table id=\"rounded-corner\" summary=\"2007 Major IT Companies' Profit\" style=\"text-align: center\">
<thead>
<tr>
<th scope=\"col\" class=\"rounded-company\"></th>
<th scope=\"col\" class=\"rounded\">Název</th>
<th scope=\"col\" class=\"rounded\">Web</th>
<th scope=\"col\" class=\"rounded\">Popis</th>
<th scope=\"col\" class=\"rounded\">Edit</th>
<th scope=\"col\" class=\"rounded-q4\">Delete</th>
</tr>
</thead>
<tbody>")
或者你可以像这样拥有'
:
string.Format(@"<table id='rounded-corner' summary='2007 Major IT Companies Profit' style='text-align: center'>
<thead>
<tr>
<th scope='col' class='rounded-company'></th>
<th scope='col' class='rounded'>Název</th>
<th scope='col' class='rounded'>Web</th>
<th scope='col' class='rounded'>Popis</th>
<th scope='col' class='rounded'>Edit</th>
<th scope='col' class='rounded-q4'>Delete</th>
</tr>
</thead>
<tbody>")
我是一名优秀的程序员,十分优秀!