<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" media="screen" href="/App_Themes/default/rss.xslt"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:evnet="http://www.mscommunities.com/rssmodule/"><channel><title>Comment Feed for C# string vs. StringBuilder (TechOff on Channel 9)</title><atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/forums/techoff/14294-c-string-vs-stringbuilder/rss/default.aspx" /><image><url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url><title>Comment Feed for C# string vs. StringBuilder (TechOff on Channel 9)</title><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/</link></image><description>C# string vs. StringBuilder</description><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/</link><language>en-us</language><pubDate>Sun, 22 Nov 2009 20:33:55 GMT</pubDate><lastBuildDate>Sun, 22 Nov 2009 20:33:55 GMT</lastBuildDate><generator>EvNet (EvNet, Version=1.0.3608.3122, Culture=neutral, PublicKeyToken=null)</generator><item><title>Re: Re: C# string vs. StringBuilder</title><description>&lt;p&gt;You should use &lt;strong&gt;Stopwatch&lt;/strong&gt; to measure small time increments. It has a very high resolution and low overhead.&lt;/p&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=508214</link><pubDate>Sun, 22 Nov 2009 20:33:56 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=508214</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/508214/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>You should use Stopwatch to measure small time increments. It has a very high resolution and low overhead.</evnet:previewtext><dc:creator>BitFlipper</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/508214/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Re: Re: Re: Re: C# string vs. StringBuilder</title><description>Fella, you quoted me.. my initial response, and counter clarification response (due to you responding TO me) was aimed at the poster I originally quoted.&lt;BR&gt;&lt;BR&gt;Boom, your high horse just got executed.</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=453641</link><pubDate>Fri, 16 Jan 2009 18:28:19 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=453641</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/453641/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Fella, you quoted me.. my initial response, and counter clarification response (due to you responding TO me) was aimed at the poster I originally quoted.Boom, your high horse just got executed.</evnet:previewtext><dc:creator>stevo_</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/453641/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Re: Re: Re: C# string vs. StringBuilder</title><description>&lt;P&gt;Not sure what your talking about. None of my replys include a link to any of my blog posts.&lt;BR&gt;&lt;BR&gt;Yes my blog is connected to my Channel 9 profile. But anyone who takes half a second to do this also has the option.&lt;BR&gt;&lt;BR&gt;I make no money off my blog. Its on a public service.&lt;BR&gt;&lt;BR&gt;I am not sure if you get some form of theraputic benifit&amp;nbsp;on being a&amp;nbsp;&lt;A href="http://onlineslangdictionary.com/definition+of/tool"&gt;tool&lt;/A&gt; but really your flaming has no basis. If it made you feel less depressed don't let me get in the way of whatever therapy you and your&amp;nbsp;&lt;A href="http://onlineslangdictionary.com/definition+of/shrink"&gt;shrink&lt;/A&gt; have worked out.&lt;/P&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=453636</link><pubDate>Fri, 16 Jan 2009 18:10:32 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=453636</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/453636/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Not sure what your talking about. None of my replys include a link to any of my blog posts.Yes my blog is connected to my Channel 9 profile. But anyone who takes half a second to do this also has the option.I make no money off my blog. Its on a public service.I am not sure if you get some form of&amp;#8230;</evnet:previewtext><dc:creator>JR Thomas</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/453636/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Re: Re: C# string vs. StringBuilder</title><description>You remember reading wrong - stringbuilders have no idea how big they'll need to be by the end, and so they have to occassionally expand themselves (an expensive operation) when they find out they have run out of space. String.Concat() on the other hand can work out exactly how long the result will be (it's the sum of all of the individual strings' lengths) and so String.Concat() is faster.&lt;BR&gt;&lt;BR&gt;For large strings or large numbers of concats, String.Concat&amp;nbsp;becomes even&amp;nbsp;more efficient.&lt;BR&gt;&lt;BR&gt;As a rule of thumb - for concatenating strings, use String.Concat. For building strings, use a StringBuilder.</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=453615</link><pubDate>Fri, 16 Jan 2009 10:14:01 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=453615</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/453615/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>You remember reading wrong - stringbuilders have no idea how big they'll need to be by the end, and so they have to occassionally expand themselves (an expensive operation) when they find out they have run out of space. String.Concat() on the other hand can work out exactly how long the result will&amp;#8230;</evnet:previewtext><dc:creator>evildictaitor</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/453615/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Re: Re: C# string vs. StringBuilder</title><description>I mean't, don't post uninspired boring links to your own blog posts, especially when the post isn't very good.. clearly the massive views of this thread (for obvious reasons) are attractive.. hmmmm views == readers of my blog.. ka ching! $$$</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=453509</link><pubDate>Thu, 15 Jan 2009 18:29:02 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=453509</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/453509/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>I mean't, don't post uninspired boring links to your own blog posts, especially when the post isn't very good.. clearly the massive views of this thread (for obvious reasons) are attractive.. hmmmm views == readers of my blog.. ka ching! $$$</evnet:previewtext><dc:creator>stevo_</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/453509/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Re: C# string vs. StringBuilder</title><description>My general rule of thumb is to use string concatenation or string.Format up to&amp;nbsp; 3 concats. Afterwhich I will go to the trouble of using a string builder or some kind of stream writer. I remember reading that string concats are more performat up to 3 concats then it goes south from there.&lt;BR&gt;&lt;BR&gt;Probably unless your doing fairly intensive concating it won't be that big of deal. Most devs I work with brush it off.</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=453504</link><pubDate>Thu, 15 Jan 2009 18:09:43 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=453504</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/453504/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>My general rule of thumb is to use string concatenation or string.Format up to&amp;nbsp; 3 concats. Afterwhich I will go to the trouble of using a string builder or some kind of stream writer. I remember reading that string concats are more performat up to 3 concats then it goes south from&amp;#8230;</evnet:previewtext><dc:creator>JR Thomas</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/453504/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: C# string vs. StringBuilder</title><description>&lt;P&gt;Please don't do that.&lt;/P&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=453474</link><pubDate>Thu, 15 Jan 2009 15:30:20 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=453474</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/453474/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Please don't do that.</evnet:previewtext><dc:creator>stevo_</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/453474/Trackback.aspx</trackback:ping></item><item><title>Re: Re: C# string vs. StringBuilder</title><description>A performance comparison of StringBuilder and String can be found in the following post &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://channel9.msdn.comrttechno.blogspot.com/2009/01/stringbuilder-vs-string-concatenations.htmltitle="&gt;http://rttechno.blogspot.com/2009/01/stringbuilder-vs-string-concatenations.html&lt;/a&gt;&lt;br&gt;&lt;/div&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=453472</link><pubDate>Thu, 15 Jan 2009 15:17:30 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=453472</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/453472/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>A performance comparison of StringBuilder and String can be found in the following post http://rttechno.blogspot.com/2009/01/stringbuilder-vs-string-concatenations.html</evnet:previewtext><dc:creator>Robin Thomas</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/453472/Trackback.aspx</trackback:ping></item><item><title>Re: C# string vs. StringBuilder</title><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;tim2s wrote:&lt;/div&gt;&lt;div&gt;﻿dbCommand Cmd = new dbCommand( "Insert (x,y,z) values(@Name,@name2..." );&lt;BR&gt;Parameter P1 = new Parameter( "@Name", dbtype);&lt;BR&gt;&lt;BR&gt;Cmd.Parameters.Add(P1);&lt;BR&gt;&lt;BR&gt;and so on then .. in the loop:&lt;BR&gt;&lt;BR&gt;for()&lt;BR&gt;{&lt;BR&gt;P1 =&amp;nbsp; value;&lt;BR&gt;P2 = other;&lt;BR&gt;P3 = "what";&lt;BR&gt;Cmd.ExecuteNonQuery();&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;no making strings in the loop, and no creating cmd's in a loop.&lt;BR&gt;this makes for nice clean code that runs fast.&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;Thank you,&lt;BR&gt;&lt;BR&gt;but i write into an *.mpl, which can not be used with the incredible SqlConnction. I have to fight with strings into an OleDb.&lt;BR&gt;&lt;BR&gt;But maybe i can convince them to use an Sql Express Db &lt;IMG src="http://channel9.msdn.com/emoticons/emotion-5.gifborder=0&gt;&lt;BR&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;BR&gt;&lt;BR&gt;well i would go for sql express for many reasons but...&lt;BR&gt;&lt;BR&gt;
&lt;P&gt;System.Data.OleDb.OleDbCommand odb = new System.Data.OleDb.OleDbCommand("");&lt;BR&gt;odb.Parameters.Add();&lt;BR&gt;&lt;BR&gt;I think the ole db parpameter makers are '?' in place of '@name'&lt;BR&gt;but the rest should I think work with oledb as well as sql, and I think odbc supports parameters also.&lt;BR&gt;&lt;/P&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=359459</link><pubDate>Thu, 18 Oct 2007 16:34:28 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=359459</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/359459/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>tim2s wrote:﻿dbCommand Cmd = new dbCommand( "Insert (x,y,z) values(@Name,@name2..." );Parameter P1 = new Parameter( "@Name", dbtype);Cmd.Parameters.Add(P1);and so on then .. in the loop:for(){P1 =&amp;nbsp; value;P2 = other;P3 = "what";Cmd.ExecuteNonQuery();}no making strings in the loop, and no&amp;#8230;</evnet:previewtext><dc:creator>figuerres</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/359459/Trackback.aspx</trackback:ping></item><item><title>Re: C# string vs. StringBuilder</title><description>dbCommand Cmd = new dbCommand( "Insert (x,y,z) values(@Name,@name2..." );&lt;br&gt;Parameter P1 = new Parameter( "@Name", dbtype);&lt;br&gt;&lt;br&gt;Cmd.Parameters.Add(P1);&lt;br&gt;&lt;br&gt;and so on then .. in the loop:&lt;br&gt;&lt;br&gt;for()&lt;br&gt;{&lt;br&gt;P1 =&amp;nbsp; value;&lt;br&gt;P2 = other;&lt;br&gt;P3 = "what";&lt;br&gt;Cmd.ExecuteNonQuery();&lt;br&gt;}&lt;br&gt;&lt;br&gt;no making strings in the loop, and no creating cmd's in a loop.&lt;br&gt;this makes for nice clean code that runs fast.&lt;br&gt;&lt;br&gt;&lt;br&gt;Thank you,&lt;br&gt;&lt;br&gt;but i write into an *.mpl, which can not be used with the incredible SqlConnction. I have to fight with strings into an OleDb.&lt;br&gt;&lt;br&gt;But maybe i can convince them to use an Sql Express Db ;)&lt;br&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=359453</link><pubDate>Thu, 18 Oct 2007 15:51:57 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=359453</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/359453/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>dbCommand Cmd = new dbCommand( "Insert (x,y,z) values(@Name,@name2..." );Parameter P1 = new Parameter( "@Name", dbtype);Cmd.Parameters.Add(P1);and so on then .. in the loop:for(){P1 =&amp;nbsp; value;P2 = other;P3 = "what";Cmd.ExecuteNonQuery();}no making strings in the loop, and no creating cmd's in a&amp;#8230;</evnet:previewtext><dc:creator>tim2s</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/359453/Trackback.aspx</trackback:ping></item><item><title>Re: C# string vs. StringBuilder</title><description>For a stringbuilder, a constant "cost" of expanding the capacity is linear w.r.t the previous capacity.&lt;br&gt;&lt;br&gt;If you choose your initial value for the StringBuilder capacity carefully, it is nearly always the most efficient solution.&lt;br&gt;&lt;br&gt;&lt;br&gt;So.&lt;br&gt;&lt;br&gt;For small or strictly constant strings, System.String is valid. For large strings, construction of strings other than with String.Format() or for strings which need to change quickly and can be large (e.g. the Value field in a text-editor or syntax editor), use a System.StringBuilder.&lt;br&gt;&lt;br&gt;In the event that you want to be able to change text &lt;i&gt;even faster &lt;/i&gt;(or holding really big values), then you'll start needing to construct your own data types over this (e.g. a linked-list of stringbuilders is more efficient for insertion than a mege-stringbuilder, both of which are vastly better than a System.String).&lt;br&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=358709</link><pubDate>Mon, 15 Oct 2007 17:15:53 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=358709</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/358709/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>For a stringbuilder, a constant "cost" of expanding the capacity is linear w.r.t the previous capacity.If you choose your initial value for the StringBuilder capacity carefully, it is nearly always the most efficient solution.So.For small or strictly constant strings, System.String is valid. For&amp;#8230;</evnet:previewtext><dc:creator>evildictaitor</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/358709/Trackback.aspx</trackback:ping></item><item><title>Re: C# string vs. StringBuilder</title><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;travis wrote:&lt;/div&gt;&lt;div&gt; 
&lt;P&gt;Well, maybe I'll just post my code.&amp;nbsp; I'm wondering if I should guess the approximate length of a stringbuilder when I create it, or just let it grow dynamically:&lt;BR&gt;&lt;BR&gt;System.Text.StringBuilder letterNavText = new System.Text.StringBuilder(&lt;STRONG&gt;1106&lt;/STRONG&gt;);&lt;BR&gt;letterNavText.Append("&amp;lt;span&amp;gt;");&lt;BR&gt;for (int i = (int)'A'; i &amp;lt;= (int)'Z'; i++)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;string letter = ((char)i).ToString();&lt;BR&gt;&amp;nbsp;if (letter == SelectedLetter)&lt;BR&gt;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append("&amp;lt;strong&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append(letter);&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append("&amp;lt;/strong&amp;gt;");&lt;BR&gt;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;else&lt;BR&gt;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append("&amp;lt;a href=\"");&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append(letter);&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append(".htm\" title=\"");&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append(letter);&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append("\"&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append(letter);&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append("&amp;lt;/a&amp;gt;");&lt;BR&gt;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;letterNavText.Append("&amp;amp;nbsp;&amp;amp;nbsp;");&lt;BR&gt;}&lt;BR&gt;letterNavText.Append("&amp;lt;/span&amp;gt;");&lt;BR&gt;LetterNav.InnerHtml = letterNavText.ToString();&lt;BR&gt;&lt;/P&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;BR&gt;&lt;BR&gt;Previous post referred to this little nugget. Sorry one of my pet peeves. If you want it&amp;nbsp;I can post a sample that does just this using a repeater.</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=358699</link><pubDate>Mon, 15 Oct 2007 16:50:41 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=358699</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/358699/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>travis wrote: 
Well, maybe I'll just post my code.&amp;nbsp; I'm wondering if I should guess the approximate length of a stringbuilder when I create it, or just let it grow dynamically:System.Text.StringBuilder letterNavText = new System.Text.StringBuilder(1106);letterNavText.Append("&amp;lt;span&amp;gt;");for&amp;#8230;</evnet:previewtext><dc:creator>odujosh</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/358699/Trackback.aspx</trackback:ping></item><item><title>Re: C# string vs. StringBuilder</title><description>Use a repeater control. Why are using making your own? :)</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=358619</link><pubDate>Mon, 15 Oct 2007 14:19:14 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=358619</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/358619/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Use a repeater control. Why are using making your own? :)</evnet:previewtext><dc:creator>odujosh</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/358619/Trackback.aspx</trackback:ping></item><item><title>Re: C# string vs. StringBuilder</title><description>&lt;P&gt;If the thread is that old and your topic is only marginally related, start a new thread.&lt;BR&gt;&lt;BR&gt;Anyway, in your&amp;nbsp;case I'd recommend using parameterized queries rather than&amp;nbsp;doing string concatenation at all.&lt;BR&gt;&lt;BR&gt;Example:&lt;BR&gt;
&lt;DIV&gt;using( OleDbCommand cmd = connection.CreateCommand() )&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;cmd.CommandText = "INSERT INTO TBLNAME (x, y, z) VALUES (?, ?, ?)";&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;cmd.Parameters.AddWithValue("x", xValue);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;cmd.Parameters.AddWithValue("y", yValue);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;cmd.Parameters.AddWithValue("z", zValue);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;cmd.ExecuteNonQuery();&lt;BR&gt;}&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;&lt;BR&gt;Not only does it remove the need for string concatenation, it eliminates the risk of &lt;a href="http://www.xkcd.com/327/"&gt;SQL injection&lt;/a&gt; as well.</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=358536</link><pubDate>Mon, 15 Oct 2007 01:54:05 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=358536</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/358536/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>If the thread is that old and your topic is only marginally related, start a new thread.Anyway, in your&amp;nbsp;case I'd recommend using parameterized queries rather than&amp;nbsp;doing string concatenation at all.Example:
using( OleDbCommand cmd = connection.CreateCommand()&amp;#8230;</evnet:previewtext><dc:creator>Sven Groot</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/358536/Trackback.aspx</trackback:ping></item><item><title>Re: C# string vs. StringBuilder</title><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;tim2s wrote:&lt;/div&gt;&lt;div&gt;﻿Hello !&lt;BR&gt;&lt;BR&gt;I have got a Problem that is related to this topic. &lt;BR&gt;I have to copy Data from one Database to an Access db and make&lt;BR&gt;some computing during this transfer. &lt;BR&gt;&lt;BR&gt;There are quite a lot of records, estimated 40K per table with several tables.&lt;BR&gt;&lt;BR&gt;Until now i'm doing the following thing for the inser Operation:&lt;BR&gt;&lt;BR&gt;for(int i = 0; i &amp;lt; myDataList.Count; i++) {&lt;BR&gt;&lt;BR&gt;cmdText = "INSERT INTO TBLNAME (x,y,z) VALUES "( ";&lt;BR&gt;cmdText += xValue + ", " + yValue + ", " + zValue + " )";&lt;BR&gt;&lt;BR&gt;DbWriter.ExecuteNonReader(cmdText);&lt;BR&gt;&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;Where DbWriter is a class with static Functions for Capsulating the database connection.&lt;BR&gt;&lt;BR&gt;Do you think it would be more useful to use a StringBuilder in this case? I mean the text has to be resetted for every item in the List, so there will be a new StringBuilder Object for every row. Is this still faster?&lt;BR&gt;&lt;BR&gt;Best Regards,&lt;BR&gt;&amp;nbsp; Tim&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;BR&gt;&lt;BR&gt;before the loop create a dbCommand and add a collection of Parameters.&amp;nbsp; then set the parameter values and call execute.&lt;BR&gt;you will remove a whole bunch of strings ....&lt;BR&gt;&amp;nbsp;&lt;BR&gt;dbCommand Cmd = new dbCommand( "Insert (x,y,z) values(@Name,@name2..." );&lt;BR&gt;Parameter P1 = new Parameter( "@Name", dbtype);&lt;BR&gt;&lt;BR&gt;Cmd.Parameters.Add(P1);&lt;BR&gt;&lt;BR&gt;and so on then .. in the loop:&lt;BR&gt;&lt;BR&gt;for()&lt;BR&gt;{&lt;BR&gt;P1 =&amp;nbsp; value;&lt;BR&gt;P2 = other;&lt;BR&gt;P3 = "what";&lt;BR&gt;Cmd.ExecuteNonQuery();&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;no making strings in the loop, and no creating cmd's in a loop.&lt;BR&gt;this makes for nice clean code that runs fast.&lt;BR&gt;&lt;BR&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=358537</link><pubDate>Mon, 15 Oct 2007 01:53:59 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=358537</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/358537/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>tim2s wrote:﻿Hello !I have got a Problem that is related to this topic. I have to copy Data from one Database to an Access db and makesome computing during this transfer. There are quite a lot of records, estimated 40K per table with several tables.Until now i'm doing the following thing for the&amp;#8230;</evnet:previewtext><dc:creator>figuerres</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/358537/Trackback.aspx</trackback:ping></item><item><title>Re: C# string vs. StringBuilder</title><description>Hello !&lt;br&gt;&lt;br&gt;I have got a Problem that is related to this topic. &lt;br&gt;I have to copy Data from one Database to an Access db and make&lt;br&gt;some computing during this transfer. &lt;br&gt;&lt;br&gt;There are quite a lot of records, estimated 40K per table with several tables.&lt;br&gt;&lt;br&gt;Until now i'm doing the following thing for the inser Operation:&lt;br&gt;&lt;br&gt;for(int i = 0; i &amp;lt; myDataList.Count; i++) {&lt;br&gt;&lt;br&gt;cmdText = "INSERT INTO TBLNAME (x,y,z) VALUES "( ";&lt;br&gt;cmdText += xValue + ", " + yValue + ", " + zValue + " )";&lt;br&gt;&lt;br&gt;DbWriter.ExecuteNonReader(cmdText);&lt;br&gt;&lt;br&gt;}&lt;br&gt;&lt;br&gt;Where DbWriter is a class with static Functions for Capsulating the database connection.&lt;br&gt;&lt;br&gt;Do you think it would be more useful to use a StringBuilder in this case? I mean the text has to be resetted for every item in the List, so there will be a new StringBuilder Object for every row. Is this still faster?&lt;br&gt;&lt;br&gt;Best Regards,&lt;br&gt;&amp;nbsp; Tim&lt;br&gt;&lt;br&gt;&lt;br&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=358522</link><pubDate>Sun, 14 Oct 2007 21:55:23 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=358522</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/358522/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Hello !I have got a Problem that is related to this topic. I have to copy Data from one Database to an Access db and makesome computing during this transfer. There are quite a lot of records, estimated 40K per table with several tables.Until now i'm doing the following thing for the inser&amp;#8230;</evnet:previewtext><dc:creator>tim2s</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/358522/Trackback.aspx</trackback:ping></item><item><title>Re: C# string vs. StringBuilder</title><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;travis wrote:&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;p&gt;&amp;nbsp;{&lt;br&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append("&amp;lt;a href=\"");&lt;br&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append(letter);&lt;br&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append(".htm\" title=\"");&lt;br&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append(letter);&lt;br&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append("\"&amp;gt;");&lt;br&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append(letter);&lt;br&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append("&amp;lt;/a&amp;gt;");&lt;br&gt;&amp;nbsp;}&lt;br&gt;&lt;/p&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;br&gt;&lt;br&gt;I think you can get away with&lt;br&gt;letterNavText.Append(&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;a href=\"" + letter + ".htm\" title=\"" + letter + "\"&amp;gt;" + letter + "&amp;lt;/a&amp;gt;"&lt;br&gt;);&lt;br&gt;&lt;br&gt;because multiple string concatenations in a single statement are auto-optimized with an inline StringBuilder replacement.&lt;br&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=123439</link><pubDate>Fri, 14 Oct 2005 16:07:36 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=123439</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/123439/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>travis wrote:&amp;nbsp;{&amp;nbsp;&amp;nbsp;letterNavText.Append("&amp;lt;a href=\"");&amp;nbsp;&amp;nbsp;letterNavText.Append(letter);&amp;nbsp;&amp;nbsp;letterNavText.Append(".htm\"&amp;#8230;</evnet:previewtext><dc:creator>Maurits</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/123439/Trackback.aspx</trackback:ping></item><item><title>Re: C# string vs. StringBuilder</title><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;MisterDonut wrote:&lt;/div&gt;&lt;div&gt;String.Format("{0}{1}{2}{3}", string1, string2, string3);&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;BR&gt;&lt;BR&gt;For perf reasons, you should consider String.Concat(string1, string2, string3) instead of the formating.&amp;nbsp; If it is only called once in your program, it probably doesn't matter, but if you are doing something over and over again, it might be worth looking into the change.&amp;nbsp; &lt;BR&gt;&lt;BR&gt;String.Concat (if I remember correctly) sums up the lengths of all the strings, build a buffer, then places the contents into that buffer.&amp;nbsp; It only allocates what it needs (different than&amp;nbsp;stringbuilder).&lt;BR&gt;&lt;BR&gt;If you are using string builder and you know how about how much space you will need, definitly instantiate it with a default capacity.&lt;BR&gt;&lt;BR&gt;I also encourage everyone to look at the Rotor source code to figure out how these things work.&amp;nbsp; It will help you make informed decisions.&amp;nbsp; But keep in mind that the Rotor source may be different than the actual MS implementation and the MS implementation could change at any time.&lt;BR&gt;&lt;BR&gt;Also, measure perf to make good decisions.</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=123443</link><pubDate>Fri, 14 Oct 2005 15:57:47 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=123443</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/123443/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>MisterDonut wrote:String.Format("{0}{1}{2}{3}", string1, string2, string3);For perf reasons, you should consider String.Concat(string1, string2, string3) instead of the formating.&amp;nbsp; If it is only called once in your program, it probably doesn't matter, but if you are doing something over and&amp;#8230;</evnet:previewtext><dc:creator>kriskdf</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/123443/Trackback.aspx</trackback:ping></item><item><title>Re: C# string vs. StringBuilder</title><description>A StringBuilder does all its operations in a given block of allocated memory. E.g. if you add something to a string, it appends it at the marked end of string, in the same memory block. A regular string operation would allocate a new chunk and copy both strings into the new chunk. It's more work.&lt;br&gt;&lt;br&gt;However since the StringBuilder needs to be instanced and all that stuff, it's not efficient enough if you're always just quickly adding two strings together, as opposed to for example composing a whole HTML page.&lt;br&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=123431</link><pubDate>Fri, 14 Oct 2005 15:37:12 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=123431</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/123431/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>A StringBuilder does all its operations in a given block of allocated memory. E.g. if you add something to a string, it appends it at the marked end of string, in the same memory block. A regular string operation would allocate a new chunk and copy both strings into the new chunk. It's more&amp;#8230;</evnet:previewtext><dc:creator>Tom Servo</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/123431/Trackback.aspx</trackback:ping></item><item><title>Re: C# string vs. StringBuilder</title><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;MisterDonut wrote:&lt;/div&gt;&lt;div&gt;One thing I do to create strings, for smaller ones, but still don't want to concatenate is this: &lt;br&gt;&lt;br&gt;String.Format("{0}{1}{2}{3}", string1, string2, string3);&lt;br&gt;&lt;br&gt;Substuting string1-3 with the characters of your choice. &lt;br&gt;&lt;br&gt;Seems to work pretty well. &lt;br&gt;&lt;br&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;br&gt;
&lt;br&gt;
If you crack open String.Format, it creates a StringBuilder internally
and uses StringBuilder.AppendFormat to accomplish its goal.&lt;br&gt;
&lt;br&gt;
Each call to String.Format results in the the allocation of an instance
of StringBuilder - I've only looked at it for two minutes or so, but it
appears that StringBuilder.AppendFormat doesn't attempt to estimate the
size of the eventual output, so if you're just using it to append
strings together, you could find out how large the output is supposed
to be and use a StringBuffer with a predetermined capacity to do the
appending.&lt;br&gt;
&lt;br&gt;
That said, in my own code, I just append the things together for code
cleanliness and if that ever shows up in our profiling roadmaps, I'll
come back and clean it up.&amp;nbsp; To date, for at least the work I do,
inefficient string appending has been a nonfactor.&lt;br&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=123426</link><pubDate>Fri, 14 Oct 2005 15:20:12 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=123426</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/123426/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>MisterDonut wrote:One thing I do to create strings, for smaller ones, but still don't want to concatenate is this: String.Format("{0}{1}{2}{3}", string1, string2, string3);Substuting string1-3 with the characters of your choice. Seems to work pretty well. 

If you crack open String.Format, it&amp;#8230;</evnet:previewtext><dc:creator>bushidocoder</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/123426/Trackback.aspx</trackback:ping></item><item><title>Re: C# string vs. StringBuilder</title><description>One thing I do to create strings, for smaller ones, but still don't want to concatenate is this: &lt;BR&gt;&lt;BR&gt;String.Format("{0}{1}{2}{3}", string1, string2, string3);&lt;BR&gt;&lt;BR&gt;Substuting string1-3 with the characters of your choice. &lt;BR&gt;&lt;BR&gt;Seems to work pretty well. &lt;BR&gt;&lt;BR&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=123420</link><pubDate>Fri, 14 Oct 2005 15:05:07 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=123420</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/123420/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>One thing I do to create strings, for smaller ones, but still don't want to concatenate is this: String.Format("{0}{1}{2}{3}", string1, string2, string3);Substuting string1-3 with the characters of your choice. Seems to work pretty well. </evnet:previewtext><dc:creator>MisterDonut</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/123420/Trackback.aspx</trackback:ping></item><item><title>Re: C# string vs. StringBuilder</title><description>For reference...&lt;BR&gt;&lt;BR&gt;The StringBuilder's initial capacity is set to 16 by default.&amp;nbsp; The capacity then increases by an order of 2 whenever the current capacity is passed.&amp;nbsp; Therefore, if the String you append to the StringBuilder causes the capacity to expand, it will increase as seen below:&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;StringBuilder sb =&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;new System.Text.StringBuilder();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;int capacity = sb.Capacity;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;for (int i=0; i&amp;lt;5000; i++)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sb.Append("a");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (capacity != sb.Capacity)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;PrintLine("Capacity:&amp;nbsp; " + sb.Capacity);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;capacity = sb.Capacity;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;
&lt;P&gt;results in the following capacity adjustments:&lt;BR&gt;Capacity: 16&lt;BR&gt;Capacity: 32&lt;BR&gt;Capacity: 64&lt;BR&gt;Capacity: 128&lt;BR&gt;Capacity: 256&lt;BR&gt;Capacity: 512&lt;BR&gt;Capacity: 1024&lt;BR&gt;Capacity: 2048&lt;BR&gt;Capacity: 4096&lt;BR&gt;Capacity: 8192&lt;BR&gt;&lt;BR&gt;&lt;/P&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=14437</link><pubDate>Wed, 28 Jul 2004 16:02:01 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=14437</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/14437/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>For reference...The StringBuilder's initial capacity is set to 16 by default.&amp;nbsp; The capacity then increases by an order of 2 whenever the current capacity is passed.&amp;nbsp; Therefore, if the String you append to the StringBuilder causes the capacity to expand, it will increase as seen&amp;#8230;</evnet:previewtext><dc:creator>Skibum</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/14437/Trackback.aspx</trackback:ping></item><item><title>Re: C# string vs. StringBuilder</title><description>&lt;P&gt;Well, maybe I'll just post my code.&amp;nbsp; I'm wondering if I should guess the approximate length of a stringbuilder when I create it, or just let it grow dynamically:&lt;BR&gt;&lt;BR&gt;System.Text.StringBuilder letterNavText = new System.Text.StringBuilder(&lt;STRONG&gt;1106&lt;/STRONG&gt;);&lt;BR&gt;letterNavText.Append("&amp;lt;span&amp;gt;");&lt;BR&gt;for (int i = (int)'A'; i &amp;lt;= (int)'Z'; i++)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;string letter = ((char)i).ToString();&lt;BR&gt;&amp;nbsp;if (letter == SelectedLetter)&lt;BR&gt;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append("&amp;lt;strong&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append(letter);&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append("&amp;lt;/strong&amp;gt;");&lt;BR&gt;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;else&lt;BR&gt;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append("&amp;lt;a href=\"");&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append(letter);&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append(".htm\" title=\"");&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append(letter);&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append("\"&amp;gt;");&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append(letter);&lt;BR&gt;&amp;nbsp;&amp;nbsp;letterNavText.Append("&amp;lt;/a&amp;gt;");&lt;BR&gt;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;letterNavText.Append("&amp;amp;nbsp;&amp;amp;nbsp;");&lt;BR&gt;}&lt;BR&gt;letterNavText.Append("&amp;lt;/span&amp;gt;");&lt;BR&gt;LetterNav.InnerHtml = letterNavText.ToString();&lt;BR&gt;&lt;/P&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=14427</link><pubDate>Wed, 28 Jul 2004 14:57:21 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=14427</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/14427/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Well, maybe I'll just post my code.&amp;nbsp; I'm wondering if I should guess the approximate length of a stringbuilder when I create it, or just let it grow dynamically:System.Text.StringBuilder letterNavText = new System.Text.StringBuilder(1106);letterNavText.Append("&amp;lt;span&amp;gt;");for (int i =&amp;#8230;</evnet:previewtext><dc:creator>travis</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/14427/Trackback.aspx</trackback:ping></item><item><title>Re: C# string vs. StringBuilder</title><description>&lt;BLOCKQUOTE&gt;&lt;div&gt;jonathanh wrote:&lt;/div&gt;&lt;div&gt;There was a semi-spirited discussion of this very topic on some Microsoft blogs a while back :-)&lt;br&gt;&lt;br&gt;I found the&amp;nbsp;blog posts&amp;nbsp;again using "&lt;a target="_blank" href="http://www.google.com/search?sourceid=navclient&amp;amp;ie=UTF-8&amp;amp;oe=UTF-8&amp;amp;q=site%3Ablogs%2Emsdn%2Ecom+string+stringbuilder"&gt;site:blogs.msdn.com string stringbuilder&lt;/a&gt;"&amp;nbsp;as a Google query.&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;br&gt;
Whoa, 83 results!&amp;nbsp; I'll start skimming and come back here if I'm still confused.&amp;nbsp; Thanks!&lt;br&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=14419</link><pubDate>Wed, 28 Jul 2004 14:11:17 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=14419</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/14419/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>jonathanh wrote:There was a semi-spirited discussion of this very topic on some Microsoft blogs a while back :-)I found the&amp;nbsp;blog posts&amp;nbsp;again using "site:blogs.msdn.com string stringbuilder"&amp;nbsp;as a Google query.&amp;nbsp;&amp;nbsp;
Whoa, 83 results!&amp;nbsp; I'll start skimming and come back here&amp;#8230;</evnet:previewtext><dc:creator>travis</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/14419/Trackback.aspx</trackback:ping></item><item><title>Re: C# string vs. StringBuilder</title><description>There was a semi-spirited discussion of this very topic on some Microsoft blogs a while back :-)&lt;BR&gt;&lt;BR&gt;I found the&amp;nbsp;blog posts&amp;nbsp;again using "&lt;a href="http://www.google.com/search?sourceid=navclient&amp;amp;ie=UTF-8&amp;amp;oe=UTF-8&amp;amp;q=site%3Ablogs%2Emsdn%2Ecom+string+stringbuilder"&gt;site:blogs.msdn.com string stringbuilder&lt;/a&gt;"&amp;nbsp;as a Google query.&amp;nbsp;&amp;nbsp;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=14385</link><pubDate>Wed, 28 Jul 2004 06:13:57 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/14294-C-string-vs-StringBuilder/?CommentID=14385</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/14385/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>There was a semi-spirited discussion of this very topic on some Microsoft blogs a while back :-)I found the&amp;nbsp;blog posts&amp;nbsp;again using "site:blogs.msdn.com string stringbuilder"&amp;nbsp;as a Google query.&amp;nbsp;&amp;nbsp;</evnet:previewtext><dc:creator>jonathanh</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/14385/Trackback.aspx</trackback:ping></item></channel></rss>