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#:

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: