C# | Int32.ToString Method | Set - 1 - GeeksforGeeks

11 Aug, 2021
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. 
This method is used to convert the numeric value of the current instance to its equivalent string representation using the specified culture-specific format information. 
Syntax:  
public string ToString (IFormatProvider provider);
Parameters: This method takes an object of type IFormatProvider which supplies culture-specific formatting information.Return Value: This method returns the string representation of the value of the current instance in the format specified by the provider parameter.Example:
csharp
// C# program to demonstrate// Int32.ToString(IFormatProvider)// Methodusing System;using System.Globalization; class GFG {     // Main Method    public static void Main()    {        // declaring and initializing Int32 value        int s1 = 15;         // creating and initializing        // the object of CultureInfo        CultureInfo provider = new CultureInfo("en-us");         // Using the method        string str = s1.ToString(provider);         // Display the value        Console.WriteLine("The Value is {0} and provider is {1}",                                           str, provider.Name);    }}
The Value is 15 and provider is en-US
 
This method is used to convert the numeric value of this instance to its equivalent string representation using the specified format and culture-specific formatting information. 
Syntax:  
public string ToString (string format, IFormatProvider provider);
Parameters:  
format: It is a standard or custom numeric format string. provider: It is an object which supplies culture-specific formatting information.  
Return Value: This method returns the string representation of the current instance specified by the format and provider parameter.Example:
csharp
// C# program to demonstrate the// Int32.ToString(String, IFormatProvider)// Methodusing System;using System.Globalization; class GFG {     // Main Method    public static void Main()    {         // declaring and initializing Int32 value        int s1 = Int32.MaxValue;         // creating and initializing        // the object of CultureInfo        CultureInfo provider = new CultureInfo("fr-FR");         // declaring and initializing format        string format = "D5";         // using the method        string str = s1.ToString(format, provider);         // Displaying the details        Console.WriteLine("The value is {0}",str);        Console.WriteLine("The Format is {0}",format);        Console.WriteLine("The Provider is {0}", provider.Name);    }}
The value is 2147483647
The Format is D5
The Provider is fr-FR
 
Reference: 
https://docs.microsoft.com/en-us/dotnet/api/system.int32.tostring?view=netframework-4.7.2
ruhelaa48
CSharp-Int32-Struct
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Destructors in C#
Extension Method in C#
HashSet in C# with Examples
Top 50 C# Interview Questions & Answers
C# | How to insert an element in an Array?
Partial Classes in C#
C# | Inheritance
C# | List Class
Difference between Hashtable and Dictionary in C#
Lambda Expressions in C#