Sunday, June 17, 2007

Formatting Strings in .NET - Desktop and Windows Mobile

Here is a great blog entry on formatting string in VB.NET or C#:

http://blogs.msdn.com/kathykam/archive/2006/03/29/564426.aspx

Here is the crux:




alignment - the minimal length of the string. Positive values are right justified; Negative values are left justified.



format string -

Numeric format specifier:

C or c = Currency
D or d = Decimal
E or e = Scientific
F or f = fixed-point
G or g = General

Standard Datetime format specifier

Custom Datetime format specifier

Enumeration format specifier



Zeros - Different meaning depending on the specifier:

Leading Zeros: D, X
Trailing Zeros: C, E, F, N, P
Nothing: G

No comments: