-
-
Notifications
You must be signed in to change notification settings - Fork 106
v2 Compatibility with string.Format
axunonb edited this page Feb 6, 2022
·
1 revision
Absolutely. The core of Smart.Format supports all the features of String.Format.
You can read about the standard features of String.Format at Microsoft's Composite Formatting reference page. The main features are:
Numbers correspond to the argument index:
Smart.Format("{0} {1}", "Hello", "World");
// Outputs: "Hello World"Determines how to format items, such as numbers and dates:
Smart.Format("{0:N3} | {1:MMMM, yyyy}", 5.5, new DateTime(2010,3,4));
// Outputs: "5.500 | March, 2010"Inserts spaces before or after the item, aligning it with other items:
Smart.Format("|{0,-10}|{1,10}|", "Left", "Right");
// Outputs: "|Left | Right|"Escape braces using double-braces:
Smart.Format("{{0}} {{{0}}} {{}}", "Zero");
// Outputs: "{0} {Zero} {}"Smart.Format uses the current culture info for formatting, or you can supply your own IFormatProvider:
Smart.Format(CultureInfo.GetCultureInfo("en-US"), "{0:C}", 1234) // Outputs: "$1,234.00"
Smart.Format(CultureInfo.GetCultureInfo("ja-JP"), "{0:C}", 1234) // Outputs: "¥1234"- Syntax, Terminology
- Placeholders and Nesting
- string.Format Compatibility
- Character Literals in Format Strings
- HTML With CSS or JavaScript
- Data Source Extensions
- Default _ DefaultFormatter
- Lists _ ListFormatter
- Choose _ ChooseFormatter
- Condition _ ConditionalFormatter
- Null _ NullFormatter
- SubString _ SubStringFormatter
- RegEx _ IsMatchFormatter
- Pluralization _ PluralLocalizationFormatter
- Localization _ LocalizationFormatter
- Templates _ TemplateFormatter
- TimeSpan _ TimeFormatter
- XML _ XElementFormatter
- Extension Methods
- Home
- Common Pitfalls
- HTML with CSS or JavaScript
- Overview
- Main Features
- Formatters
- Extra Features
- Console and StringBuilder
- TemplateFormatter
- SmartSettings to control Smart.Format behavior
- Additional Info
- License
3.6