C# Convert ToString(Boolean, IFormatProvider)

Description

Convert ToString(Boolean, IFormatProvider) converts the specified Boolean value to its equivalent string representation.

Syntax

Convert.ToString(Boolean, IFormatProvider) has the following syntax.


public static string ToString(
  bool value,
  IFormatProvider provider
)

Parameters

Convert.ToString(Boolean, IFormatProvider) has the following parameters.

  • value - The Boolean value to convert.
  • provider - An instance of an object. This parameter is ignored.

Returns

Convert.ToString(Boolean, IFormatProvider) method returns The string representation of value.

Example


using System;// w  ww. j  a  v  a2  s. c o  m
using System.Globalization;

class MainClass
{
    public static void Main( )
    {
        NumberFormatInfo provider = new NumberFormatInfo();

        provider.NegativeSign = "neg ";
        provider.PositiveSign = "pos ";

        provider.NumberDecimalSeparator = ".";
        provider.NumberGroupSeparator = ",";
        provider.NumberGroupSizes = new int[ ] { 3 };
        provider.NumberNegativePattern = 0;

        Console.WriteLine( Convert.ToString( true ));
        Console.WriteLine( Convert.ToString( true, provider ) );
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version