Transform string values with built-in string operations inside a Smart String.
The String source handles a string value and exposes common string operations as selectors, so you can transform text directly in the format string. For example, {name.ToUpper} outputs the value of name in uppercase.
| Selector | Description |
|---|---|
Length |
The number of characters in the string. |
ToUpper, ToLower
|
Convert to upper or lower case using the active culture. |
ToUpperInvariant, ToLowerInvariant
|
Convert to upper or lower case using the invariant culture. |
Trim, TrimStart, TrimEnd
|
Remove surrounding whitespace. |
Capitalize |
Convert the first character to upper case. |
CapitalizeWords |
Convert the first letter of each word to upper case. |
ToCharArray |
Convert the string to a character array. |
ToBase64, FromBase64
|
Encode to, or decode from, a UTF–8 Base64 string. |
The following examples show how to use a few common string operations with the String source:
Smart.Format("{0.ToUpper}", "hello"); // "HELLO"
Smart.Format("{0.Capitalize}", "hello"); // "Hello"
Smart.Format("{0.CapitalizeWords}", "hello world"); // "Hello World"
Smart.Format("Length: {0.Length}", "hello"); // "Length: 5"