String.ToString String.ToString String.ToString String.ToString Method

定義

このインスタンスの値を String に変換します。Converts the value of this instance to a String.

オーバーロード

ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider)

String のこのインスタンスを返します。実際の変換処理は実行されません。Returns this instance of String; no actual conversion is performed.

ToString() ToString() ToString() ToString()

String のこのインスタンスを返します。実際の変換処理は実行されません。Returns this instance of String; no actual conversion is performed.

ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider)

String のこのインスタンスを返します。実際の変換処理は実行されません。Returns this instance of String; no actual conversion is performed.

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 IFormatProvider IFormatProvider IFormatProvider

(予約済み) カルチャ固有の書式情報を提供するオブジェクト。(Reserved) An object that supplies culture-specific formatting information.

戻り値

現在の文字列。The current string.

実装

注釈

providerは予約されており、現在この操作に参加していません。provider is reserved, and does not currently participate in this operation.

このメソッドは、現在の文字列をそのまま返すだけなので、直接呼び出す必要はありません。Because this method simply returns the current string unchanged, there is no need to call it directly.

ToString() ToString() ToString() ToString()

String のこのインスタンスを返します。実際の変換処理は実行されません。Returns this instance of String; no actual conversion is performed.

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

戻り値

現在の文字列。The current string.

メソッドのToString例を次に示します。この例では、メソッドはToString明示的に呼び出されないことに注意してください。The following example demonstrates the ToString method.Note that the example does not explicitly call the ToString method. 代わりに、メソッドは複合書式指定機能によって暗黙的に呼び出されます。Instead, the method is called implicitly by the composite formatting feature.

using namespace System;
int main()
{
   String^ str1 = "123";
   String^ str2 = "abc";
   Console::WriteLine( "Original str1: {0}", str1 );
   Console::WriteLine( "Original str2: {0}", str2 );
   Console::WriteLine( "str1 same as str2?: {0}", Object::ReferenceEquals( str1, str2 ) );
   str2 = str1;
   Console::WriteLine();
   Console::WriteLine( "New str2:      {0}", str2 );
   Console::WriteLine( "str1 same as str2?: {0}", Object::ReferenceEquals( str1, str2 ) );
}

/*
This code produces the following output:
Original str1: 123
Original str2: abc
str1 same as str2?: False

New str2:      123
str1 same as str2?: True
*/
using System;

class stringToString {
    public static void Main() {
    String str1 = "123";
    String str2 = "abc";

    Console.WriteLine("Original str1: {0}", str1);
    Console.WriteLine("Original str2: {0}", str2);
    Console.WriteLine("str1 same as str2?: {0}", Object.ReferenceEquals(str1, str2));

    str2 = str1.ToString();
    Console.WriteLine();
    Console.WriteLine("New str2:      {0}", str2);
    Console.WriteLine("str1 same as str2?: {0}", Object.ReferenceEquals(str1, str2));
    }
}
/*
This code produces the following output:
Original str1: 123
Original str2: abc
str1 same as str2?: False

New str2:      123
str1 same as str2?: True
*/
 _

Class stringToString
   
   Public Shared Sub Main()
      Dim str1 As [String] = "123"
      Dim str2 As [String] = "abc"
      
      Console.WriteLine("Original str1: {0}", str1)
      Console.WriteLine("Original str2: {0}", str2)
      Console.WriteLine("str1 same as str2?: {0}", [Object].ReferenceEquals(str1, str2))
      
      str2 = str1.ToString()
      Console.WriteLine()
      Console.WriteLine("New str2:      {0}", str2)
      Console.WriteLine("str1 same as str2?: {0}", [Object].ReferenceEquals(str1, str2))
   End Sub
End Class
'
'This code produces the following output:
'Original str1: 123
'Original str2: abc
'str1 same as str2?: False
'
'New str2:      123
'str1 same as str2?: True
'

注釈

このメソッドは、現在の文字列をそのまま返すだけなので、直接呼び出す必要はありません。Because this method simply returns the current string unchanged, there is no need to call it directly. この例に示すように、通常、複合書式指定操作で暗黙的に呼び出されます。It is usually called implicitly in a composite formatting operation, as the example shows.

こちらもご覧ください

適用対象