Char.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.

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

參數

provider
IFormatProvider

(保留) 物件,提供特定文化特性格式資訊。(Reserved) An object that supplies culture-specific formatting information.

傳回

這個執行個體值的字串表示,如同 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)

將指定的 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

參數

c
Char

要轉換的 Unicode 字元。The Unicode character to convert.

傳回

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.

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.

範例

下列程式碼範例將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

另請參閱

適用於