Converts this instance to its equivalent String representation using the specified format and culture-specific format information.
Parameters
- format
- The format information
- formatProvider
- An IFormatProvider that supplies culture-specific formatting information.
Return Value
The String representation of this instance as specified by format and provider.
The following is an example on formatting a TdNumber when converting to a String.
public void ToStringExample()
{
TdNumber value;
String result;
System.Globalization.NumberFormatInfo formatInfo;
value = TdNumber.Parse("9987365422318132e-8");
// FIXED FORMAT
// Using Default FormatProvider.
// result will be 99873654.22
result = value.ToString("f2");
// result will be 99873654.2232
result= value.ToString("f4");
// Going to change the the Decimal Separator
formatInfo.NumberDecimalSeparator = "##";
// result will be 99873654##223218
result = value.ToString("f6");
// CURRENCY FORMAT
// result will be $99,873,654.22
result = value.ToString("C2");
// Going to change the Currency Group Separator
numberFormat.CurrencyGroupSeparator = @"@@";
// Going to chage the Currency Symbol
numberFormat.CurrencySymbol = "?";
// result will be ?99@@873@@654.22
// NOTE: There is a property, CurrencyDecimalSeparator,
// that is used only for currency. Therefore,
// NumberDecimalSeparator has no affect
// on a string formatted with a "c".
result = value.ToString("c4");
}
Target Platforms: Windows 7, Windows 8, Windows 8.1, Windows 10, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2