A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/c-sharp/uint32-tostring-method-in-c-sharp-with-examples-set-1/ below:

UInt32.ToString() Method in C# with Examples | Set - 1

UInt32.ToString() Method in C# with Examples | Set - 1

Last Updated : 11 Jul, 2025

UInt32.ToString Method

is used to convert the numeric value of the current UInt32 instance to its equivalent string representation. There are 4 methods in the overload list of this method as follows:

  1. ToString(IFormatProvider) Method
  2. ToString(String, IFormatProvider) Method
  3. ToString() Method
  4. ToString(String) Method

Here, we will discuss the first two methods.

ToString(IFormatProvider) Method

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, which consists of a sequence of digits ranging from 0 to 9, without a sign or leading zeros.

Example: csharp
// C# program to demonstrate
// UInt32.ToString(IFormatProvider)
// Method
using System;
using System.Globalization;

class GFG {

    // Main Method
    public static void Main()
    {
        // declaring and initializing
        // UInt32 value
        uint s1 = 49848;

        // 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);
    }
}
Output:
The Value is 49848 and provider is en-US
UInt32.ToString(String, IFormatProvider) Method

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 numeric format string. provider: It is an object which supplies culture-specific formatting information about the current instance.
Return Value:

This method returns the string representation of the current instance specified by the

format

and

provider

parameter.

Exception:

This method will give

FormatException

if the

format

parameter is invalid.

Example: csharp
// C# program to demonstrate the
// UInt32.ToString(String, 
// IFormatProvider) Method
using System;
using System.Globalization;

class GFG {

    // Main Method
    public static void Main()
    {

        // declaring and initializing UInt32 value
        uint s1 = UInt32.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);
    }
}
Output:
The value is 4294967295
The Format is D5
The Provider is fr-FR
Reference:

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4