String.Copy メソッドとは? わかりやすく解説

String.Copy メソッド

指定した String と同じ値を使用してString新しインスタンス作成します

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

例外例外
例外種類条件

ArgumentNullException

strnull 参照 (Visual Basic では Nothing) です。

使用例使用例

次のコード例では、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'
*/
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からString.Copy メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からString.Copy メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からString.Copy メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「String.Copy メソッド」の関連用語

String.Copy メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



String.Copy メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS