
' The example displays the following output:įor more information about formatting with format providers, see the Format Providers section. The example displays the following output:Ĭonsole.WriteLine(cost.ToString("C", New ("en-US"))) For example, the following statement displays a currency value by using the formatting conventions of the en-US culture. Using format providers to implement the formatting conventions of a specific culture. int integerValue = 60312 Ĭonsole.WriteLine(integerValue.ToString("X")) // Displays EB98.Ĭonsole.WriteLine(integerValue.ToString("X")) ' Displays EB98.įor more information about format specifiers, see the ToString Method and Format Strings section. For example, the "X" format specifier in the following statement converts an integer to the string representation of a hexadecimal value. For more information, see the Override the ToString Method section later in this topic.ĭefining format specifiers that enable the string representation of an object's value to take multiple forms.

Overriding the Object.ToString method to define a custom string representation of an object's value. NET provides several ways to modify and extend its default formatting support. The basic mechanism for formatting is the default implementation of the Object.ToString method, which is discussed in the Default Formatting Using the ToString Method section later in this topic. For information about serialization and deserialization, see Serialization in. For more information, see Parsing Strings. A parsing operation creates an instance of a data type from its string representation.
