String.Copy メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim str As String Dim returnValue As String returnValue = String.Copy(str)
戻り値
str と同じ値を持つ String。


次のコード例では、2 つの変数で参照された、まったく異なる 2 つの文字列を表示した後、一方の文字列のコピーを作成しています。その後、新しい文字列への参照を 2 つ目の変数に代入し、最後に、両方の変数によって参照される 2 つの文字列を表示しています。まったく同じ文字列が表示されることがわかります。
' Sample for String.Copy() Imports System Class Sample Public Shared Sub Main() Dim str1 As String = "abc" Dim str2 As String = "xyz" Console.WriteLine("1) str1 = '{0}'", str1) Console.WriteLine("2) str2 = '{0}'", str2) Console.WriteLine("Copy...") str2 = [String].Copy(str1) Console.WriteLine("3) str1 = '{0}'", str1) Console.WriteLine("4) str2 = '{0}'", str2) End Sub 'Main End Class 'Sample ' 'This example produces the following results: '1) str1 = 'abc' '2) str2 = 'xyz' 'Copy... '3) str1 = 'abc' '4) str2 = 'abc' '
// Sample for String.Copy() using System; class Sample { public static void Main() { string str1 = "abc"; string str2 = "xyz"; Console.WriteLine("1) str1 = '{0}'", str1); Console.WriteLine("2) str2 = '{0}'", str2); Console.WriteLine("Copy..."); str2 = String.Copy(str1); Console.WriteLine("3) str1 = '{0}'", str1); Console.WriteLine("4) str2 = '{0}'", str2); } } /* This example produces the following results: 1) str1 = 'abc' 2) str2 = 'xyz' Copy... 3) str1 = 'abc' 4) str2 = 'abc' */
// Sample for String::Copy() using namespace System; int main() { String^ str1 = "abc"; String^ str2 = "xyz"; Console::WriteLine( "1) str1 = '{0}'", str1 ); Console::WriteLine( "2) str2 = '{0}'", str2 ); Console::WriteLine( "Copy..." ); str2 = String::Copy( str1 ); Console::WriteLine( "3) str1 = '{0}'", str1 ); Console::WriteLine( "4) str2 = '{0}'", str2 ); } /* This example produces the following results: 1) str1 = 'abc' 2) str2 = 'xyz' Copy... 3) str1 = 'abc' 4) str2 = 'abc' */
// Sample for String.Copy() import System.*; class Sample { public static void main(String[] args) { String str1 = "abc"; String str2 = "xyz"; Console.WriteLine("1) str1 = '{0}'", str1); Console.WriteLine("2) str2 = '{0}'", str2); Console.WriteLine("Copy..."); str2 = String.Copy(str1); Console.WriteLine("3) str1 = '{0}'", str1); Console.WriteLine("4) str2 = '{0}'", str2); } //main } //Sample /* This example produces the following results: 1) str1 = 'abc' 2) str2 = 'xyz' Copy... 3) str1 = 'abc' 4) str2 = 'abc' */

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からString.Copy メソッドを検索する場合は、下記のリンクをクリックしてください。

- String.Copy メソッドのページへのリンク