Char.ToString Method

Definition

将此实例的值转换为其等效的字符串表示形式。Converts the value of this instance to its equivalent string representation.

Overloads

ToString(IFormatProvider)

使用指定的区域性特定格式信息将此实例的值转换为它的等效字符串表示形式。Converts the value of this instance to its equivalent string representation using the specified culture-specific format information.

ToString(Char)

将指定的 Unicode 字符转换为它的等效字符串表示形式。Converts the specified Unicode character to its equivalent string representation.

ToString()

将此实例的值转换为其等效的字符串表示形式。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.

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

Parameters

provider
IFormatProvider

(保留)一个对象,用于提供区域性特定的格式设置信息。(Reserved) An object that supplies culture-specific formatting information.

Returns

String

此实例的值的字符串表示形式,由 provider 指定。The string representation of the value of this instance as specified by provider.

Implements

Examples

下面的代码示例演示 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

Remarks

忽略 provider 参数;它不参与此操作。The provider parameter is ignored; it does not participate in this operation.

See also

ToString(Char)

将指定的 Unicode 字符转换为它的等效字符串表示形式。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

Parameters

c
Char

要转换的 Unicode 字符。The Unicode character to convert.

Returns

String

c 值的字符串表示形式。The string representation of the value of c.

Examples

下面的代码示例演示 ToStringThe 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

See also

ToString()

将此实例的值转换为其等效的字符串表示形式。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

Returns

String

此实例的值的字符串表示形式。The string representation of the value of this instance.

Examples

下面的代码示例演示 ToStringThe 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

See also

Applies to