<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: Formatting strings</title>
	<link>http://ask.metafilter.com/50971/Formatting-strings/</link>
	<description>Comments on Ask MetaFilter post Formatting strings</description>
	<pubDate>Wed, 15 Nov 2006 06:26:29 -0800</pubDate>
	<lastBuildDate>Wed, 15 Nov 2006 06:26:29 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: Formatting strings</title>
		<link>http://ask.metafilter.com/50971/Formatting-strings</link>	
		<description>String manipulation in C#:  I know that the String.Format method can format numeric data so that {0:#,###} transforms 1234 into the string &quot;1,234&quot;.  There are lots of standard formatters like {0:C} for currency, and endless ways to format DateTime objects.  But is there a similar shorthand to format a string or to apply a mask to it?   &lt;br /&gt;&lt;br /&gt; I have a db table that contains ISBN values (look at the bar code on any book and you will see the value I am talking about).  It is stored in the db as a char(10), since by definition an ISBN-10 is always 10 characters.  But the formatting of an isbn is always n-nnn-nnnnn-n.  The final character is sometimes a letter, so just using {0:#-###-#####-#} to format the display will not work.  I know I can parse it out by using substrings (&quot;{0}-{1}-{2}-{3}&quot;, value.Substring(0,1), value.Substring(1,3), etc.), but that seems awfully verbose.  Is there a shorthand method that I am missing?</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2006:site.50971</guid>
		<pubDate>Wed, 15 Nov 2006 05:36:53 -0800</pubDate>
		<dc:creator>Lokheed</dc:creator>
		
			<category>c#</category>
		
			<category>code</category>
		
			<category>string</category>
		
			<category>format</category>
		
	</item> <item>
		<title>By: pjern</title>
		<link>http://ask.metafilter.com/50971/Formatting-strings#771756</link>	
		<description>{0:#-###-#####-*}?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.50971-771756</guid>
		<pubDate>Wed, 15 Nov 2006 06:26:29 -0800</pubDate>
		<dc:creator>pjern</dc:creator>
	</item><item>
		<title>By: plinth</title>
		<link>http://ask.metafilter.com/50971/Formatting-strings#771760</link>	
		<description>The real way to do this is to represent your ISBN value as a class and override the ToString method for it.  At that point you should also be able to creat IFormatProvider objects to allow more flexible formatting.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.50971-771760</guid>
		<pubDate>Wed, 15 Nov 2006 06:29:56 -0800</pubDate>
		<dc:creator>plinth</dc:creator>
	</item><item>
		<title>By: Lokheed</title>
		<link>http://ask.metafilter.com/50971/Formatting-strings#771783</link>	
		<description>*thunk*&lt;br&gt;
&lt;br&gt;
Of course.  I should have thought of that, thanks.  Much cleaner.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.50971-771783</guid>
		<pubDate>Wed, 15 Nov 2006 07:04:44 -0800</pubDate>
		<dc:creator>Lokheed</dc:creator>
	</item>
	</channel>
</rss>
