次の方法で共有


String.Concat メソッド (Object )

指定した Object 配列の要素の String 形式を連結します。

Overloads Public Shared Function Concat( _
   ByVal ParamArray args() As Object _) As String
[C#]
public static string Concat(   params object[] args);
[C++]
public: static String* Concat(Object* args __gc[]);
[JScript]
public static function Concat(
   args : Object[]) : String;

パラメータ

戻り値

args の要素の String 形式の値の連結結果。

例外

例外の種類 条件
ArgumentNullException args が null 参照 (Visual Basic では Nothing) です。

解説

Empty 文字列は、配列内の任意の null オブジェクトの代わりに使用されます。

使用例

[Visual Basic, C#, C++] Concat メソッドを Object 配列と共に使用する方法については、次のコード例を参照してください。

 
Imports System



Public Class ConcatTest
    
    Public Shared Sub Main()
        Dim t1 As New Test1()
        Dim t2 As New Test2()
        Dim i As Integer = 16
        Dim s As String = "Demonstration"
        Dim o As Object() = {t1, i, t2, s}
        
        ' create a group of objects
        
        ' place the objects in an array
        
        ' concatenate the objects together as a string. To do this,
        ' the ToString method in the objects is called
        Console.WriteLine(String.Concat(o))
    End Sub 'Main
End Class 'ConcatTest


' imagine these test classes are full-fledged objects...
Class Test1
End Class 'Test1

Class Test2
End Class 'Test2

[C#] 
using System;

public class ConcatTest {
    public static void Main() {

        // create a group of objects
        Test1 t1 = new Test1();
        Test2 t2 = new Test2();
        int i = 16;
        string s = "Demonstration";

        // place the objects in an array
        object [] o = { t1, i, t2, s };

        // concatenate the objects together as a string. To do this,
        // the ToString method in the objects is called
        Console.WriteLine(string.Concat(o));
    }
}

// imagine these test classes are full-fledged objects...
class Test1 {
}

class Test2 {
}

[C++] 
#using <mscorlib.dll>
using namespace System;

// imagine these test classes are full-fledged objects...
__gc class Test1 {
};

__gc class Test2 {
};

int main() {

        // create a group of objects
        Test1* t1 = new Test1();
        Test2* t2 = new Test2();
        int i = 16;
        String* s = S"Demonstration";

        // place the objects in an array
        Object* o[] = { t1, __box(i), t2, s };

        // concatenate the objects together as a string. To do this,
        // the ToString method in the objects is called
        Console::WriteLine(String::Concat(o));
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard

参照

String クラス | String メンバ | System 名前空間 | String.Concat オーバーロードの一覧 | Object | Join