views:

570

answers:

5

I am constantly forgetting what the special little codes are for formatting .NET strings. Either through ToString() or using String.Format(). Alignment, padding, month vs. minute (month is uppercase M?), abbreviation vs. full word, etc. I can never remember.

I have the same problem with regexes, but luckily there's Expresso to help me out. It's awesome.

Is there a tool like Expresso for experimenting with formatted strings on standard types like DateTime and float and so on?

+1  A: 

You could use the Snippy plugin for Reflector to run little code snippets.

RSlaughter
+1  A: 

PowerShell works great for testing format strings. From PowerShell you can load your assembly and work with the objects and methods you want to test. You could also just create a string on the command line and test out different formatting options.

You can use the static method from the string class:

$teststring = 'Currency - {0:c}.  And a date - {1:ddd d MMM}.  And a plain string - {2}'
[string]::Format($teststring, 160.45, Get-Date, 'Test String')

Or PowerShell has a built in format operator

$teststring = 'Currency - {0:c}.  And a date - {1:ddd d MMM}.  And a plain string - {2}'
$teststring -f 160.45, Get-Date, 'Test String'
Steven Murawski
+2  A: 

http://www.sellsbrothers.com/tools/#FormatDesigner

Pretty close but it's lacking the alignment stuff that you get outside of ToString(). I like that it's updated in real-time though.
Scott Bilas
+3  A: 

Snippet Compiler is a great tool in general for quick small app testing. Instead of cluttering your Visual Studio with a million ConsoleApplication79 projects, just use this. I have it and use it constantly.

BFree