StringBuilder を使用した VB コードがたくさんあります。それらを XML リテラルに変更することを検討しています。パフォーマンスに関しては、StringBuilder よりも高速ですか? それとも遅いですか?
これは XML リテラルの例です。
Dim bookString = <bookstore xmlns="http://examples.books.com">
<book publicationdate=<%= publicationdate %> ISBN=<%= isbn %>>
<title>ASP.NET Book</title>
<price><%= price %></price>
<author>
<first-name><%= a.FirstName %></first-name>
<last-name><%= a.LastName %></last-name>
</author>
</book>
</bookstore>.Value
これは StringBuilder の使用例です。
Dim stringBuilder = new StringBuilder()
stringBuilder.Append("<bookstore xmlns="http://examples.books.com">")
stringBuilder.Append("<book publicationdate=<%= publicationdate %> ISBN=<%= isbn %>>")
stringBuilder.Append("<title>ASP.NET Book</title>")
stringBuilder.Append("<price><%= price %></price>")
stringBuilder.Append("<author>")
stringBuilder.Append("<first-name><%= a.FirstName %></first-name>")
stringBuilder.Append("<last-name><%= a.LastName %></last-name>")
stringBuilder.Append("</author>")
stringBuilder.Append("</book>")
stringBuilder.Append("</bookstore>")
Dim bookString = stringBuilder.toString()