Skip to content

Commit fd0b9e4

Browse files
committed
Added "Formatting .NET types" section in README.md
1 parent 751dbe1 commit fd0b9e4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,22 @@ Console.WriteLine(format.Format(1234.56, CultureInfo.InvariantCulture));
3030
- Formats dates and durations using DateTime and TimeSpan values instead of numeric values like Excel.
3131
- Targets net20 and netstandard1.0 for max compatibility.
3232

33+
## Formatting .NET types
34+
35+
The `Format()` method takes a value of type `object` as parameter. Internally, the value is cast or converted to a specific .NET type depending on the kind of number format:
36+
37+
Format Kind | Example | .NET type|Conversion strategy
38+
-|-|-|-
39+
Number | 0.00 |double|Convert.ToDouble()
40+
Fraction | 0/0 |double|Convert.ToDouble()
41+
Exponent | \#0.0E+0 |double|Convert.ToDouble()
42+
Date/Time| hh\:mm |DateTime|Convert.ToDateTime()
43+
Duration | \[hh\]\:mm|TimeSpan|Cast to TimeSpan
44+
General | General |(any)|Convert.ToString()
45+
Text | ;;;"Text: "@|string|Convert.ToString()
46+
47+
In case of errors, `Format()` returns the value from `Convert.ToString()`.
48+
3349
## TODO/notes
3450

3551
- 'General' is formatted with `.ToString()` instead of Excel conventions.

0 commit comments

Comments
 (0)