Single.ToString Method in C# | Set - 1 Last Updated : 01 May, 2019 Comments Improve Suggest changes Like Article Like Report Single.ToString() Method is used to convert the numeric value of the current instance to its equivalent string representation. There are 4 methods in the overload list of this method as follows: ToString(String) Method ToString() Method ToString(IFormatProvider) Method ToString(String, IFormatProvider) Method Here, we will discuss the first two methods. ToString(String) Method This method is used to convert the numeric value of the current instance to its equivalent string representation, using the specified format. Syntax: public string ToString (string format); Here, it takes a numeric format string. Return Value: This method returns the string representation of the value of the current instance as specified by format. Exceptions: This method throws FormatException if format is invalid. Example 1: csharp // C# program to demonstrate the // Single.ToString(String) Method using System; class GFG { // Main Method public static void Main() { try { // Declaring and initializing value float value = 565998.1564f; // Declaring and initializing format string s = "E04"; // using the method string str = value.ToString(s); // Display the value Console.WriteLine("String value is {0}", str); } catch (FormatException e) { Console.WriteLine("Format is invalid."); Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: String value is 5.6600E+005 Example 2: For FormatException csharp // C# program to demonstrate the // Single.ToString(String) Method using System; class GFG { // Main Method public static void Main() { try { // Declaring and initializing value float value = 1623325.62412f; // Declaring and initializing format string s = "a"; // using the method string str = value.ToString(s); // Display the value Console.WriteLine("String value is {0}", str); } catch (FormatException e) { Console.WriteLine("Format is invalid."); Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: Format is invalid. Exception Thrown: System.FormatException ToString() Method This method is used to convert the numeric value of the current instance to its equivalent string representation. Syntax: public override string ToString (); Return Value: This method returns a string which represents the value of this instance. Below programs illustrate the use of Single.ToString() Method: Example 1: csharp // C# program to demonstrate the // Single.ToString() Method using System; class GFG { // Main Method public static void Main() { // Declaring and initializing value float value = 792759354.39503305f; // using ToString() method string res = value.ToString(); // Display the value Console.WriteLine("String value is {0}", res); } } Output: String value is 7.927594E+08 Example 2: csharp // C# program to demonstrate the // Single.ToString() Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { // calling get() method get(Single.MaxValue); get(Single.MinValue); get(40f); get(424967295.5858f); } // defining get() method public static void get(float value) { // using ToString() method string res = value.ToString(); // Display the value Console.WriteLine("String value is {0}", res); } } Output: String value is 3.402823E+38 String value is -3.402823E+38 String value is 40 String value is 4.249673E+08 Reference: https://docs.microsoft.com/en-us/dotnet/api/system.single.tostring?view=netstandard-2.1 Comment More infoAdvertise with us Next Article Single.ToString Method in C# | Set - 1 K Kirti_Mangal Follow Improve Article Tags : C# CSharp-method CSharp-Single-Struct Similar Reads Single.ToString() Method in C# | Set - 2 Single.ToString() Method is used to convert the numeric value of the current instance to its equivalent string representation. There are 4 methods in the overload list of this method as follows: ToString(String) Method ToString() Method ToString(IFormatProvider) Method ToString(String, IFormatProvid 2 min read C# | Int32.ToString Method | Set - 1 Int32.ToString Method is used to converts the numeric value of the current Int32 instance to its equivalent string representation. There are 4 methods in the overload list of this method as follows:Here, we will discuss the first two methods. ToString(IFormatProvider) Method This method is used to c 2 min read C# | Int64.ToString Method | Set - 1 Int64.ToString Method is used to convert the numeric value of the current instance to its equivalent string representation. There are 4 methods in the overload list of this method as follows: ToString(IFormatProvider) MethodToString(String, IFormatProvider) MethodToString( ) MethodToString(String) M 2 min read C# | Int16.ToString Method | Set - 1 Int16.ToString Method is used to convert the numeric value of the current instance to its equivalent string representation. There are 4 methods in the overload list of this method as follows: ToString(IFormatProvider) Method ToString(String, IFormatProvider) Method ToString() Method ToString(String) 2 min read StringBuilder.ToString Method in C# This method is used to converts the value of this instance to a String. A new String object is created and initialized to get the character sequence from this StringBuilder object and then String is returned by ToString(). Subsequent changes to this sequence contained by Object do not affect the con 2 min read Like