Char.ToString Метод

Определение

Converts the value of this instance to its equivalent string representation.Converts the value of this instance to its equivalent string representation.

Перегрузки

ToString(IFormatProvider)

Converts the value of this instance to its equivalent string representation using the specified culture-specific format information.Converts the value of this instance to its equivalent string representation using the specified culture-specific format information.

ToString(Char)

Converts the specified Unicode character to its equivalent string representation.Converts the specified Unicode character to its equivalent string representation.

ToString()

Converts the value of this instance to its equivalent string representation.Converts the value of this instance to its equivalent string representation.

ToString(IFormatProvider)

Converts the value of this instance to its equivalent string representation using the specified culture-specific format information.Converts the value of this instance to its equivalent string representation using the specified culture-specific format information.

public:
 virtual System::String ^ ToString(IFormatProvider ^ provider);
public string ToString (IFormatProvider provider);
override this.ToString : IFormatProvider -> string
Public Function ToString (provider As IFormatProvider) As String

Параметры

provider
IFormatProvider

(Reserved) An object that supplies culture-specific formatting information.(Reserved) An object that supplies culture-specific formatting information.

Возвращаемое значение

The string representation of the value of this instance as specified by provider.The string representation of the value of this instance as specified by provider.

Реализации

Примеры

В следующем примере кода демонстрируется перегрузка ToString.The following code example demonstrates an overload of ToString.

using namespace System;
int main()
{
   char ch = 'a';
   Console::WriteLine( ch ); // Output: "a"
   Console::WriteLine( Char::ToString( 'b' ) ); // Output: "b"
}

using System;

public class ToStringSample {
    public static void Main() {
        char ch = 'a';
        Console.WriteLine(ch.ToString());		// Output: "a"

        Console.WriteLine(Char.ToString('b'));	// Output: "b"
    }
}
Module ToStringSample

    Sub Main()

        Dim ch As Char
        ch = "a"c
        Console.WriteLine(ch.ToString())        ' Output: "a"

        Console.WriteLine(Char.ToString("b"c))  ' Output: "b"

    End Sub

End Module

Комментарии

Параметр provider игнорируется; Он не участвует в этой операции.The provider parameter is ignored; it does not participate in this operation.

Дополнительно

ToString(Char)

Converts the specified Unicode character to its equivalent string representation.Converts the specified Unicode character to its equivalent string representation.

public:
 static System::String ^ ToString(char c);
public static string ToString (char c);
static member ToString : char -> string
Public Shared Function ToString (c As Char) As String

Параметры

c
Char

The Unicode character to convert.The Unicode character to convert.

Возвращаемое значение

The string representation of the value of c.The string representation of the value of c.

Примеры

В следующем примере кода демонстрируется ToString.The following code example demonstrates ToString.

using namespace System;
int main()
{
   char ch = 'a';
   Console::WriteLine( ch ); // Output: "a"
   Console::WriteLine( Char::ToString( 'b' ) ); // Output: "b"
}

using System;

public class ToStringSample {
    public static void Main() {
        char ch = 'a';
        Console.WriteLine(ch.ToString());		// Output: "a"

        Console.WriteLine(Char.ToString('b'));	// Output: "b"
    }
}
Module ToStringSample

    Sub Main()

        Dim ch As Char
        ch = "a"c
        Console.WriteLine(ch.ToString())        ' Output: "a"

        Console.WriteLine(Char.ToString("b"c))  ' Output: "b"

    End Sub

End Module

Дополнительно

ToString()

Converts the value of this instance to its equivalent string representation.Converts the value of this instance to its equivalent string representation.

public:
 override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String

Возвращаемое значение

The string representation of the value of this instance.The string representation of the value of this instance.

Примеры

В следующем примере кода демонстрируется ToString.The following code example demonstrates ToString.

using namespace System;
int main()
{
   char ch = 'a';
   Console::WriteLine( ch ); // Output: "a"
   Console::WriteLine( Char::ToString( 'b' ) ); // Output: "b"
}

using System;

public class ToStringSample {
    public static void Main() {
        char ch = 'a';
        Console.WriteLine(ch.ToString());		// Output: "a"

        Console.WriteLine(Char.ToString('b'));	// Output: "b"
    }
}
Module ToStringSample

    Sub Main()

        Dim ch As Char
        ch = "a"c
        Console.WriteLine(ch.ToString())        ' Output: "a"

        Console.WriteLine(Char.ToString("b"c))  ' Output: "b"

    End Sub

End Module

Дополнительно

Применяется к