<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>API Design: The why of "StringBuilder.AppendFormat()" design</title><link>http://blogs.msdn.com/b/kathykam/archive/2006/05/11/595793.aspx</link><description>"Why does StrignBuilder.AppendFormat() need anything more than AppendFormat(string, object[])?" -- Curious StringBuilder.AppendForamt user 
 This is a great question. Before I begin, let's visit what overloads AppendFormat has.... AppendFormat( string</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title> Kathy Kam API Design The why of StringBuilder AppendFormat design | Paid Surveys</title><link>http://blogs.msdn.com/b/kathykam/archive/2006/05/11/595793.aspx#9654896</link><pubDate>Fri, 29 May 2009 19:57:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9654896</guid><dc:creator> Kathy Kam API Design The why of StringBuilder AppendFormat design | Paid Surveys</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://paidsurveyshub.info/story.php?title=kathy-kam-api-design-the-why-of-stringbuilder-appendformat-design"&gt;http://paidsurveyshub.info/story.php?title=kathy-kam-api-design-the-why-of-stringbuilder-appendformat-design&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9654896" width="1" height="1"&gt;</description></item><item><title>re: API Design: The why of "StringBuilder.AppendFormat()" design</title><link>http://blogs.msdn.com/b/kathykam/archive/2006/05/11/595793.aspx#5622297</link><pubDate>Tue, 23 Oct 2007 14:12:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5622297</guid><dc:creator>buzz44</dc:creator><description>&lt;p&gt;Hey there,&lt;/p&gt;
&lt;p&gt;I just started using the StringBuilder class and AppendFormat method recently. What is the point of having the AppendFormat (format as String, ParamArray args() as Object) overloaded member?&lt;/p&gt;
&lt;p&gt;A ParamArray lets you have an unlimited number of parameters, but to format it you *need to know* what parametres, i.e. what index.&lt;/p&gt;
&lt;p&gt;I can do this...&lt;/p&gt;
&lt;p&gt;StringBuilder.AppendFormat(&amp;quot;{0} {1}&amp;quot;, Parameters)&lt;/p&gt;
&lt;p&gt;... but it doesn't know what is the last object in the ParamArray. I want to be able to format EACH object in the ParamArray. Are there a format syntax I have not found yet or do I have to format each object individually in a For loop so I can loop through each object in the ParamArray and stop on the last one.&lt;/p&gt;
&lt;p&gt;Hope that makes sense,&lt;/p&gt;
&lt;p&gt;buzz.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5622297" width="1" height="1"&gt;</description></item><item><title>re: API Design: The why of &amp;quot;StringBuilder.AppendFormat()&amp;quot; design</title><link>http://blogs.msdn.com/b/kathykam/archive/2006/05/11/595793.aspx#649474</link><pubDate>Wed, 28 Jun 2006 11:46:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:649474</guid><dc:creator>Hammoudeh Ahmad</dc:creator><description>I am wondering why some methods in BCL as String.Format and StringBuilder.AppendFormat were designed to accept their substituting values parameters as parameters of type object or array of objects (or param array) as in AppendFormat(string, object) and AppendFormat(string, object[]). Why were these methods not designed to accept strings instead of objects? I think accepting those parameters as strings - when possible - would be better as long as the parameter on which to apply formatting is a string and as long as every class in .NET inherits System.Object. This way, the calling client for this method has to pass strings and by uniformly calling object.ToString() - or another custom method maybe - when passing the substituting values. This way; boxing would be avoided when passing value types to the AppendFormat method! Personally, I keep calling the .ToString method explicitly to pass that function a string reference which deos not cause boxing as System.String as a reference type.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=649474" width="1" height="1"&gt;</description></item><item><title>re: API Design: The why of &amp;quot;StringBuilder.AppendFormat()&amp;quot; design</title><link>http://blogs.msdn.com/b/kathykam/archive/2006/05/11/595793.aspx#596569</link><pubDate>Sat, 13 May 2006 01:46:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:596569</guid><dc:creator>KathyKam [MSFT]</dc:creator><description>Yes, the C# and C++ compilers favor the flat parameters, but with out those overload, you'll always have to create an array. By the way, the CLR engine actually creates an array internally to handle those overloads. Theoretically, one performance optimization we can do is to not create an underlying array. &amp;nbsp;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=596569" width="1" height="1"&gt;</description></item><item><title>re: API Design: The why of &amp;amp;quot;StringBuilder.AppendFormat()&amp;amp;quot; design</title><link>http://blogs.msdn.com/b/kathykam/archive/2006/05/11/595793.aspx#595876</link><pubDate>Fri, 12 May 2006 09:01:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:595876</guid><dc:creator>Random Reader</dc:creator><description>Shahar: you left off the &amp;quot;params&amp;quot; keyword in your sample.
&lt;br&gt;
&lt;br&gt;But you're right; both the C# and C++ compilers favor flat parameters over arrays marked with ParamArrayAttribute as part of their normal overload resolution process. &amp;nbsp;They generate nearly identical IL for the same code.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=595876" width="1" height="1"&gt;</description></item><item><title>re: API Design: The why of &amp;quot;StringBuilder.AppendFormat()&amp;quot; design</title><link>http://blogs.msdn.com/b/kathykam/archive/2006/05/11/595793.aspx#595874</link><pubDate>Fri, 12 May 2006 08:54:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:595874</guid><dc:creator>KathyKam [MSFT]</dc:creator><description>I should be more explicit... creating those overload is an opportunity for us to optimize it. Not creating array is one way, but we can do other performance optomizations.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=595874" width="1" height="1"&gt;</description></item><item><title>re: API Design: The why of &amp;quot;StringBuilder.AppendFormat()&amp;quot; design</title><link>http://blogs.msdn.com/b/kathykam/archive/2006/05/11/595793.aspx#595805</link><pubDate>Fri, 12 May 2006 06:09:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:595805</guid><dc:creator>Shahar Prish - MSFT</dc:creator><description>&amp;lt;&amp;lt;&amp;lt;&lt;br&gt;Allows the option for the CLR engine to do performance optimization (without array creation) on common scenarios. (However, the CLR engine has not taken up on this option...)&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&lt;br&gt;Is this really an optimization the &amp;quot;CLR engine&amp;quot; needs to do? It seems more like an optimization the compiler does when it generates the IL.&lt;br&gt;&lt;br&gt;Furthermore, the C# compiler seems to do the right thing and not create an array - in the following sample, &amp;quot;No array&amp;quot; gets output to the console.&lt;br&gt;class Program&lt;br&gt;{&lt;br&gt; &amp;nbsp; &amp;nbsp;static void f(object[] o)&lt;br&gt; &amp;nbsp; &amp;nbsp;{&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Console.WriteLine(&amp;quot;yes array&amp;quot;);&lt;br&gt; &amp;nbsp; &amp;nbsp;}&lt;br&gt; &amp;nbsp; &amp;nbsp;static void f(object o)&lt;br&gt; &amp;nbsp; &amp;nbsp;{&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Console.WriteLine(&amp;quot;No array&amp;quot;);&lt;br&gt; &amp;nbsp; &amp;nbsp;}&lt;br&gt; &amp;nbsp; &amp;nbsp;static void Main(string[] args)&lt;br&gt; &amp;nbsp; &amp;nbsp;{&lt;br&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;f(1);&lt;br&gt; &amp;nbsp; &amp;nbsp;}&lt;br&gt;}&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=595805" width="1" height="1"&gt;</description></item></channel></rss>