mike's web log

 

Blog Search


(Supports AND)

 

Google Ads

 

Technorati

 

Feed

Subscribe to the RSS feed for this blog.

See this post for info on full versus truncated feeds.

 

Quote

Most people prefer internal mechanisms for determining for themselves what is right and what is wrong, but perceive other people as needing to be regulated by laws.

— Antanas Mockus, mayor of Bogotá, Columbia



 

Navigation






<September 2010>
SMTWTFS
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789


 

25 Most-Visited Entries

 

Categories

  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
  RSS
 

Blogs I Read

 

Contact

Email me
 

Blog Statistics

Dates
First entry - 6/27/2003
Most recent entry - 8/26/2010

Totals
Posts - 2109
Comments - 2170
Hits - 1,138,425

Averages
Entries/day - 0.80
Comments/entry - 1.03
Hits/day - 434

Update every 30 minutes. Last: 6:46 PM Pacific

 
   |  String formatting

posted at 09:39 PM | | [4] |

I was reading the Daily Grind, as I do, and Gunderloy pointed to a blog entry by Steve Tibbet that describes how to do "string formatting in C#", as it says, although of course exactly the same formatting applies in all .NET languages.

I haven't studied it in detail, but it seems to me that a lot of what's in the blog entry is in the docs already. Admittedly, it ain't always easy to find stuff in the docs. I think we improved this somewhat for 2.0 with better indexing and cross-referencing and more examples. But anyway, for your reference (in addition to Steve's blog entry), may I remind you that the docs for string formatting are here:

Composite formatting
Standard numeric formatting (examples)
Custom numeric formatting (examples)
Standard date formatting (examples)
Custom date formatting (examples)

There's more, but that's enough for now. If you can remember these when you need 'em, they can be darn useful.

I'll remind you also that you can achieve string formatting with String.Format or better yet, an overload of the ToString method that's available in just about every class.

Strings seem to be the flavor of the week. Jeff Atwood posted something about strings in which he quotes Brad Abrams saying Brad's favorite class in .NET is String. And he notes also that Karl Seguin is of the opinion that using a format string is easier than concatenating together some convoluted string to display. That's a lesson I should be learning more thoroughly.

And for completeness's sake, Jeff also links to some other folks with thoughts on strings, including Steve Tibbet, which is where we started, I guess.

[categories]