VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/single-tostring-method-in-c-sharp-set-1/

⇱ Single.ToString Method in C# | Set - 1 - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Single.ToString Method in C# | Set - 1

Last Updated : 11 Jul, 2025
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:
Output:
String value is 5.6600E+005
Example 2: For FormatException
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:
Output:
String value is 7.927594E+08
Example 2:
Output:
String value is 3.402823E+38
String value is -3.402823E+38
String value is 40
String value is 4.249673E+08
Reference:
Comment
Article Tags:

Explore