User Tools

Site Tools


stringformat

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
stringformat [2018/01/27 21:10] wolfgangriedmannstringformat [2019/07/30 10:02] (current) wolfgangriedmann
Line 10: Line 10:
  
 For more details please see the Microsoft documentation: [[https://docs.microsoft.com/en-us/dotnet/api/system.string.format#Starting|Get started with the String.Format method]] For more details please see the Microsoft documentation: [[https://docs.microsoft.com/en-us/dotnet/api/system.string.format#Starting|Get started with the String.Format method]]
 +
 +Here are a few samples:
 +<code>String.Format( "'{0,10}'", 100 ) -> '       100'
 +String.Format( "'{0,-10}'", 100 ) -> '100       '
 +String.Format( "{0:0000000}", 1234 ) -> 0001234
 +String.Format( "{0:0000}", 1234 ) -> 1234
 +String.Format( "'{0,10}'", 1234 ) -> '      1234'
 +String.Format( "'{0,4}'", 1234 ) -> '1234'
 +nValue:ToString( "10" ) -> 11234 
 +nValue:ToString( "4" ) -> 4
 +String.Format( "{0:yyyy.MM.dd HH:mm:ss}", DateTime.Now ) -> 2019.07.30 11:49:36
 +
 +nDecimal := 123456789.987654321m
 +String.Format( "{0}", nDecimal )  -> 123456789,987654321
 +nDecimal:ToString( "############.##" ) -> 123456789,99
 +nDecimal:ToString( "############.#######" ) -> 123456789,9876543
 +nDecimal:ToString( "#.##" ) -> 123456789,99
 +
 +nValue := 123
 +nValue:ToString( "0000" ) ) -> 0123
 +nValue:ToString( "####" ) ) -> 123
 +String.Format( "'{0,4}'", 123 ) -> ' 123'</code>
stringformat.txt · Last modified: 2019/07/30 10:02 by wolfgangriedmann