StringConcatとは? わかりやすく解説

String.Concat メソッド (String, String, String, String)

指定した 4 つString インスタンス連結します。

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

Public Shared Function Concat
 ( _
    str0 As String, _
    str1 As String, _
    str2 As String, _
    str3 As String _
) As String
Dim str0 As String
Dim str1 As String
Dim str2 As String
Dim str3 As String
Dim returnValue As String

returnValue = String.Concat(str0, str1, str2, str3)
public:
static String^ Concat (
    String^ str0, 
    String^ str1, 
    String^ str2, 
    String^ str3
)

パラメータ

str0

第 1 の String

str1

第 2 の String

str2

第 3String

str3

第 4 の String

戻り値
str0str1str2、および str3連結結果

解説解説
使用例使用例

この Concat メソッド使用してDataBinding オブジェクト出力生成する例については、次のコード例参照してください

myDataBindingCollection = DataBindings
myEnumerator = myDataBindingCollection.GetEnumerator()
While myEnumerator.MoveNext()

   myDataBinding2 = CType(myEnumerator.Current, DataBinding)
   Dim dataBindingOutput1, dataBindingOutput2, dataBindingOutput3
 As [String]
   dataBindingOutput1 = [String].Concat("The property name is
 ", myDataBinding2.PropertyName)
   dataBindingOutput2 = [String].Concat("The property type is
 ", myDataBinding2.PropertyType.ToString(), "-",
 dataBindingOutput1)
   dataBindingOutput3 = [String].Concat("The expression is ",
 myDataBinding2.Expression, "-", dataBindingOutput2)
   WriteToFile(dataBindingOutput3)

   myDataBindingExpression2 = [String].Concat("<%#",
 myDataBinding2.Expression, "%>")
   myStringReplace2 = myDataBinding2.PropertyName.Replace(".",
 "-")
   myHtmlControlDesignBehavior.SetAttribute(myStringReplace2, myDataBindingExpression2,
 True)
   Dim index As Integer
 = myStringReplace2.IndexOf("-"c)
End While ' while loop ends
myDataBindingCollection = DataBindings;
myEnumerator = myDataBindingCollection.GetEnumerator();
while(myEnumerator.MoveNext())
{

   myDataBinding2 = (DataBinding)myEnumerator.Current;
   String dataBindingOutput1,dataBindingOutput2,dataBindingOutput3;
   dataBindingOutput1=String.Concat("The property name is ",myDataBinding2.PropertyName);
   dataBindingOutput2=String.Concat("The property type is ",myDataBinding2.PropertyType.ToString()
,"-",dataBindingOutput1);
   dataBindingOutput3=String.Concat("The expression is ",myDataBinding2.Expression
,"-",dataBindingOutput2);
   WriteToFile(dataBindingOutput3);
   myDataBindingExpression2 = String.Concat("<%#",myDataBinding2.Expression
,"%>");
   myStringReplace2 = myDataBinding2.PropertyName.Replace(".","-");
   myHtmlControlDesignBehavior.SetAttribute(myStringReplace2,myDataBindingExpression2
,true);
   int index = myStringReplace2.IndexOf('-');
}// while loop ends
myDataBindingCollection = get_DataBindings();
myEnumerator = myDataBindingCollection.GetEnumerator();
while (myEnumerator.MoveNext()) {
    myDataBinding2 = (DataBinding)(myEnumerator.get_Current());
    String dataBindingOutput1, dataBindingOutput2, 
        dataBindingOutput3;
    dataBindingOutput1 = String.Concat("The property name is ", 
        myDataBinding2.get_PropertyName());
    dataBindingOutput2 = String.Concat("The property type is ", 
        myDataBinding2.get_PropertyType().ToString(), "-", 
        dataBindingOutput1);
    dataBindingOutput3 = String.Concat("The expression is ", 
        myDataBinding2.get_Expression(), "-", dataBindingOutput2);
    WriteToFile(dataBindingOutput3);

    myDataBindingExpression2 = String.Concat("<%#", 
        myDataBinding2.get_Expression(), "%>");
    myStringReplace2 = myDataBinding2.get_PropertyName().
        Replace(".", "-");
    myHtmlControlDesignBehavior.SetAttribute(myStringReplace2, 
        myDataBindingExpression2, true);
    int index = myStringReplace2.IndexOf("-");
} // while loop ends
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

String.Concat メソッド

String1 つ上のインスタンス、または Object1 つ上のインスタンスString 形式の値を連結します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
String.Concat (Object) 指定したオブジェクトString 形式作成します

.NET Compact Framework によってサポートされています。

String.Concat (Object[]) 指定した Object 配列要素String 形式連結します。

.NET Compact Framework によってサポートされています。

String.Concat (String[]) 指定した String 配列要素連結します。

.NET Compact Framework によってサポートされています。

String.Concat (Object, Object) 指定した 2 つオブジェクトString 形式連結します。

.NET Compact Framework によってサポートされています。

String.Concat (String, String) 指定した 2 つString インスタンス連結します。

.NET Compact Framework によってサポートされています。

String.Concat (Object, Object, Object) 指定した 3 つのオブジェクトString 形式連結します。

.NET Compact Framework によってサポートされています。

String.Concat (String, String, String) 指定した 3 つの String インスタンス連結します。

.NET Compact Framework によってサポートされています。

String.Concat (Object, Object, Object, Object) 4 つ指定したオブジェクトと、オプション可変長パラメータ リスト指定した任意のオブジェクトString 表現連結します。
String.Concat (String, String, String, String) 指定した 4 つString インスタンス連結します。

.NET Compact Framework によってサポートされています。

参照参照

String.Concat メソッド (String[])

指定した String 配列要素連結します。

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

例外例外
例外種類条件

ArgumentNullException

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

解説解説
使用例使用例

Concat メソッドString 配列と共に使用する方法については、次のコード例参照してください

Imports System

Public Class ConcatTest
    
    Public Shared Sub Main()
        Dim s As String()
 = {"hello ", "and ",
 "welcome ", "to ", "this ", "demo! "}
        
        ' make an array of strings. Note that we have included spaces
        
        ' put all the strings together
        Console.WriteLine(String.Concat(s))
        
        ' sort the strings, and put them together
        Array.Sort(s)
        Console.WriteLine(String.Concat(s))
    End Sub 'Main
End Class 'ConcatTest
using System;

public class ConcatTest {
    public static void Main()
 {

        // make an array of strings. Note that we have included spaces
        string [] s = { "hello ", "and ",
 "welcome ", "to ", "this ", "demo!
 " };

        // put all the strings together
        Console.WriteLine(string.Concat(s));

        // sort the strings, and put them together
        Array.Sort(s);
        Console.WriteLine(string.Concat(s));
    }
}
using namespace System;
int main()
{
   
   // make an array of strings. Note that we have included spaces
   array<String^>^s = {"hello ","and ","welcome ","to
 ","this ","demo! "};
   
   // put all the strings together
   Console::WriteLine( String::Concat( s ) );
   
   // sort the strings, and put them together
   Array::Sort( s );
   Console::WriteLine( String::Concat( s ) );
}

import System.*;

public class ConcatTest
{
    public static void main(String[]
 args)
    {
        // make an array of strings. Note that we have included spaces
        String s[] =  { "hello ", "and ", "welcome ",
 "to ", "this ", "demo! " };
        // put all the strings together
        Console.WriteLine(String.Concat(s));
        // sort the strings, and put them together
        Array.Sort(s);
        Console.WriteLine(String.Concat(s));
    } //main
} //ConcatTest
import System;

public class ConcatTest {
    public static function
 Main() : void {

        // make an array of strings. Note that we have included spaces
        var s : String [] = [ "hello ", "and ",
 "welcome ", "to ", "this ", "demo!
 "];

        // put all the strings together
        Console.WriteLine(System.String.Concat(s));

        // sort the strings, and put them together
        System.Array.Sort(s);
        Console.WriteLine(System.String.Concat(s));
    }
}
ConcatTest.Main();
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

String.Concat メソッド (Object, Object, Object, Object)

4 つ指定したオブジェクトと、オプション可変長パラメータ リスト指定した任意のオブジェクトString 表現連結します。

このメソッドは、CLS準拠していません。  CLS準拠する代替必要な場合は、Concat(Object[]) を使用してください

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

<CLSCompliantAttribute(False)> _
Public Shared Function Concat
 ( _
    arg0 As Object, _
    arg1 As Object, _
    arg2 As Object, _
    arg3 As Object _
) As String
Dim arg0 As Object
Dim arg1 As Object
Dim arg2 As Object
Dim arg3 As Object
Dim returnValue As String

returnValue = String.Concat(arg0, arg1, arg2, arg3)
[CLSCompliantAttribute(false)] 
public static string Concat
 (
    Object arg0,
    Object arg1,
    Object arg2,
    Object arg3
)
[CLSCompliantAttribute(false)] 
public:
static String^ Concat (
    Object^ arg0, 
    Object^ arg1, 
    Object^ arg2, 
    Object^ arg3
)
/** @attribute CLSCompliantAttribute(false) */ 
public static String Concat (
    Object arg0, 
    Object arg1, 
    Object arg2, 
    Object arg3
)
CLSCompliantAttribute(false) 
public static function Concat
 (
    arg0 : Object, 
    arg1 : Object, 
    arg2 : Object, 
    arg3 : Object
) : String

パラメータ

arg0

第 1 の Object

arg1

第 2 の Object

arg2

第 3Object

arg3

第 4 の Object

戻り値
arg0arg1arg2、および arg3 の各パラメータString 形式の値の連結結果

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

String.Concat メソッド (String, String, String)

指定した 3 つの String インスタンス連結します。

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

Public Shared Function Concat
 ( _
    str0 As String, _
    str1 As String, _
    str2 As String _
) As String

パラメータ

str0

第 1 の String

str1

第 2 の String

str2

第 3String

戻り値
str0str1、および str2連結結果

解説解説
使用例使用例

この Concat メソッド使用してコンソールへの出力生成する例については、次のコード例参照してください

Option Explicit
Option Strict

Imports System
Imports System.Globalization

Public Class MainClass
    
    Public Shared Sub Main()
        Dim dt As DateTime = DateTime.Now
        Dim myformat() As String
 =  {"d", "D", _
                                    "f", "F",
 _
                                    "g", "G",
 _
                                    "m", _
                                    "r", _
                                    "s", _
                                    "t", "T",
 _
                                    "u", "U",
 _
                                    "y", _
                                    "dddd, MMMM dd yyyy",
 _
                                    "ddd, MMM d ""'""yy",
 _
                                    "dddd, MMMM dd",
 _
                                    "M/yy", _
                                    "dd-MM-yy"}
        Dim mydate As String
        Dim i As Integer
        For i = 0 To myformat.Length - 1
            mydate = dt.ToString(myformat(i), DateTimeFormatInfo.InvariantInfo)
            Console.WriteLine(String.Concat(myformat(i), "
 :", mydate))
        Next i

    ' Output.
    '
    ' d :08/17/2000
    ' D :Thursday, August 17, 2000
    ' f :Thursday, August 17, 2000 16:32
    ' F :Thursday, August 17, 2000 16:32:32
    ' g :08/17/2000 16:32
    ' G :08/17/2000 16:32:32
    ' m :August 17
    ' r :Thu, 17 Aug 2000 23:32:32 GMT
    ' s :2000-08-17T16:32:32
    ' t :16:32
    ' T :16:32:32
    ' u :2000-08-17 23:32:32Z
    ' U :Thursday, August 17, 2000 23:32:32
    ' y :August, 2000
    ' dddd, MMMM dd yyyy :Thursday, August 17 2000
    ' ddd, MMM d "'"yy :Thu, Aug 17 '00
    ' dddd, MMMM dd :Thursday, August 17
    ' M/yy :8/00
    ' dd-MM-yy :17-08-00
    End Sub 'Main 
End Class 'MainClass
 using System;
 using System.Globalization; 
 
public class MainClass { 
    public static void Main(string[]
 args)  {
        DateTime dt = DateTime.Now;
        String[] format = {
            "d", "D",
            "f", "F",
            "g", "G",
            "m",
            "r",
            "s",
            "t", "T",
            "u", "U",
            "y",
            "dddd, MMMM dd yyyy",
            "ddd, MMM d \"'\"yy",
            "dddd, MMMM dd",
            "M/yy",
            "dd-MM-yy",
        };
        String date;
        for (int i = 0; i < format.Length;
 i++) {
            date = dt.ToString(format[i], DateTimeFormatInfo.InvariantInfo);
            Console.WriteLine(String.Concat(format[i], " :" , date));
        }
  
   /** Output.
    *
    * d :08/17/2000
    * D :Thursday, August 17, 2000
    * f :Thursday, August 17, 2000 16:32
    * F :Thursday, August 17, 2000 16:32:32
    * g :08/17/2000 16:32
    * G :08/17/2000 16:32:32
    * m :August 17
    * r :Thu, 17 Aug 2000 23:32:32 GMT
    * s :2000-08-17T16:32:32
    * t :16:32
    * T :16:32:32
    * u :2000-08-17 23:32:32Z
    * U :Thursday, August 17, 2000 23:32:32
    * y :August, 2000
    * dddd, MMMM dd yyyy :Thursday, August 17 2000
    * ddd, MMM d "'"yy :Thu, Aug 17 '00
    * dddd, MMMM dd :Thursday, August 17
    * M/yy :8/00
    * dd-MM-yy :17-08-00
    */
    }
}
using namespace System;
using namespace System::Globalization;
void main()
{
   DateTime dt = DateTime::Now;
   array<String^>^format = {L"d",L"D",L"f",L"F",L"g",L"G",L"m",L"r",L"s",L"t",L"T",L"u",L"U",L"y",L"dddd,
 MMMM dd yyyy",L"ddd, MMM d \"'\"yy",L"dddd, MMMM
 dd",L"M/yy",L"dd-MM-yy"};
   String^ date;
   for ( int i = 0; i < format->Length;
 i++ )
   {
      date = dt.ToString( format[ i ], DateTimeFormatInfo::InvariantInfo );
      Console::WriteLine( String::Concat( format[ i ], L" :", date ) );

   }
   
   /** Output.
       *
       * d :08/17/2000
       * D :Thursday, August 17, 2000
       * f :Thursday, August 17, 2000 16:32
       * F :Thursday, August 17, 2000 16:32:32
       * g :08/17/2000 16:32
       * G :08/17/2000 16:32:32
       * m :August 17
       * r :Thu, 17 Aug 2000 23:32:32 GMT
       * s :2000-08-17T16:32:32
       * t :16:32
       * T :16:32:32
       * u :2000-08-17 23:32:32Z
       * U :Thursday, August 17, 2000 23:32:32
       * y :August, 2000
       * dddd, MMMM dd yyyy :Thursday, August 17 2000
       * ddd, MMM d "'"yy :Thu, Aug 17 '00
       * dddd, MMMM dd :Thursday, August 17
       * M/yy :8/00
       * dd-MM-yy :17-08-00
       */
}

import System.*;
import System.Globalization.*;

public class MainClass
{
    public static void main(String[]
 args)
    {
        DateTime dT = DateTime.get_Now();
        String format[] =  { "d", "D", "f", "F",
 "g", "G", "m", "r", "s", "t",
 
            "T", "u", "U", "y", "dddd,
 MMMM dd yyyy", "ddd, MMM d \"'\"yy", 
            "dddd, MMMM dd", "M/yy", "dd-MM-yy" };
        String date;
        for (int i = 0; i < format.get_Length();
 i++) {
            date = dT.ToString(format[i], DateTimeFormatInfo.get_InvariantInfo());
            Console.WriteLine(String.Concat(format[i], " :", date));
        }
    } //main 
} //MainClass 

 /** Output.
    *
    * d :08/17/2000
    * D :Thursday, August 17, 2000
    * f :Thursday, August 17, 2000 16:32
    * F :Thursday, August 17, 2000 16:32:32
    * g :08/17/2000 16:32
    * G :08/17/2000 16:32:32
    * m :August 17
    * r :Thu, 17 Aug 2000 23:32:32 GMT
    * s :2000-08-17T16:32:32
    * t :16:32
    * T :16:32:32
    * u :2000-08-17 23:32:32Z
    * U :Thursday, August 17, 2000 23:32:32
    * y :August, 2000
    * dddd, MMMM dd yyyy :Thursday, August 17 2000
    * ddd, MMM d "'"yy :Thu, Aug 17 '00
    * dddd, MMMM dd :Thursday, August 17
    * M/yy :8/00
    * dd-MM-yy :17-08-00
    */
import System;
import System.Globalization; 
 

var dt : DateTime = DateTime.Now;
var format : String[] = [
    "d", "D",
    "f", "F",
    "g", "G",
    "m",
    "r",
    "s",
    "t", "T",
    "u", "U",
    "y",
    "dddd, MMMM dd yyyy",
    "ddd, MMM d \"'\"yy",
    "dddd, MMMM dd",
    "M/yy",
    "dd-MM-yy",
    ];
var date : String;
for (var i : int = 0; i
 < format.Length; i++) {
    date = dt.ToString(format[i], DateTimeFormatInfo.InvariantInfo);
    Console.WriteLine(format[i] + " :" + date);
}

  
   /** Output.
    *
    * d :08/17/2000
    * D :Thursday, August 17, 2000
    * f :Thursday, August 17, 2000 16:32
    * F :Thursday, August 17, 2000 16:32:32
    * g :08/17/2000 16:32
    * G :08/17/2000 16:32:32
    * m :August 17
    * r :Thu, 17 Aug 2000 23:32:32 GMT
    * s :2000-08-17T16:32:32
    * t :16:32
    * T :16:32:32
    * u :2000-08-17 23:32:32Z
    * U :Thursday, August 17, 2000 23:32:32
    * y :August, 2000
    * dddd, MMMM dd yyyy :Thursday, August 17 2000
    * ddd, MMM d "'"yy :Thu, Aug 17 '00
    * dddd, MMMM dd :Thursday, August 17
    * M/yy :8/00
    * dd-MM-yy :17-08-00
    */
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

String.Concat メソッド (String, String)

指定した 2 つString インスタンス連結します。

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

解説解説
使用例使用例

個人の名前の、名、ミドル ネーム、姓を連結する方法については、次のコード例参照してください

Imports System

Public Class ConcatTest
    
    Public Shared Sub Main()
        Dim fName As String
 = "Simon"
        Dim mName As String
 = "Jake"
        Dim lName As String
 = "Harrows"
        
        ' we want to simply quickly add this person's name together
        
        ' because we want a name to appear with a space in between each
 name, 
        ' put a space on the front of the middle, and last name, allowing
 for
        ' the fact that a space may already be there
        mName = " " + mName.Trim()
        lName = " " + lName.Trim()
        
        ' this line simply concatenates the two strings
        Console.WriteLine("Welcome to this page, '{0}'!",
 String.Concat(String.Concat(fName, mName), lName))
    End Sub 'Main
End Class 'ConcatTest
using System;

public class ConcatTest {
    public static void Main()
 {

        // we want to simply quickly add this person's name together
        string fName = "Simon";
        string mName = "Jake";
        string lName = "Harrows";

        // because we want a name to appear with a space in between
 each name, 
        // put a space on the front of the middle, and last name, allowing
 for
        // the fact that a space may already be there
        mName = " " + mName.Trim();
        lName = " " + lName.Trim();

        // this line simply concatenates the two strings
        Console.WriteLine("Welcome to this page, '{0}'!",
 string.Concat( string.Concat(fName, mName),
 lName ) );
    }
}
using namespace System;
int main()
{
   
   // we want to simply quickly add this person's name together
   String^ fName = "Simon";
   String^ mName = "Jake";
   String^ lName = "Harrows";
   
   // because we want a name to appear with a space in between each
 name, 
   // put a space on the front of the middle, and last name, allowing
 for
   // the fact that a space may already be there
   mName = String::Concat(  " ", mName->Trim() );
   lName = String::Concat(  " ", lName->Trim() );
   
   // this line simply concatenates the two strings
   Console::WriteLine( "Welcome to this page, '{0}'!",
 String::Concat( String::Concat( fName, mName ), lName ) );
}

import System.*;

public class ConcatTest
{
    public static void main(String[]
 args)
    {
        // we want to simply quickly add this person's name together
        String fName = "Simon";
        String mName = "Jake";
        String lName = "Harrows";

        // because we want a name to appear with a space in between
 each name, 
        // put a space on the front of the middle, and last name, allowing
 for
        // the fact that a space may already be there
        mName = " " + mName.Trim();
        lName = " " + lName.Trim();

        // this line simply concatenates the two strings
        Console.WriteLine("Welcome to this page, '{0}'!",
 
            String.Concat(String.Concat(fName, mName), lName));
    } //main
} //ConcatTest
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

String.Concat メソッド (Object, Object, Object)

指定した 3 つのオブジェクトString 形式連結します。

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

Public Shared Function Concat
 ( _
    arg0 As Object, _
    arg1 As Object, _
    arg2 As Object _
) As String
Dim arg0 As Object
Dim arg1 As Object
Dim arg2 As Object
Dim returnValue As String

returnValue = String.Concat(arg0, arg1, arg2)
public:
static String^ Concat (
    Object^ arg0, 
    Object^ arg1, 
    Object^ arg2
)

パラメータ

arg0

第 1 の Object

arg1

第 2 の Object

arg2

第 3Object

戻り値
arg0arg1、およびarg2String 形式の値の連結結果

解説解説
使用例使用例

Concat メソッドコード例次に示します

Imports System
Imports Microsoft.VisualBasic
 _

Class stringConcat5
   
   Public Shared Sub Main()
      Dim i As Integer =
 - 123
      Dim o As [Object] = i
      Dim objs() As [Object] = {- 123, - 456,
 - 789}
      
      Console.WriteLine("Concatenate 1, 2, and 3 objects:")
      Console.WriteLine("1) {0}", [String].Concat(o))
      Console.WriteLine("2) {0}", [String].Concat(o,
 o))
      Console.WriteLine("3) {0}", [String].Concat(o,
 o, o))
      
      Console.WriteLine(vbCrLf & "Concatenate 4 objects and
 a variable length parameter list:")
      Console.WriteLine("4) {0}", [String].Concat(o,
 o, o, o, o))
      
      Console.WriteLine(vbCrLf & "Concatenate a 3 element
 object array:")
      Console.WriteLine("5) {0}", [String].Concat(objs))
   End Sub 'Main
End Class 'stringConcat5
'
'This example produces the following output:
'Concatenate 1, 2, and 3 objects:
'1) -123
'2) -123-123
'3) -123-123-123
'
'Concatenate 4 objects and a variable length parameter list:
'4) -123-123-123-123-123
'
'Concatenate a 3 element object array:
'5) -123-456-789
'
using System;

class stringConcat5 {
    public static void Main()
 {
    int i = -123;
    Object o = i;
    Object[] objs = new Object[] {-123, -456, -789};

    Console.WriteLine("Concatenate 1, 2, and 3 objects:");
    Console.WriteLine("1) {0}", String.Concat(o));
    Console.WriteLine("2) {0}", String.Concat(o, o));
    Console.WriteLine("3) {0}", String.Concat(o, o, o));

    Console.WriteLine("\nConcatenate 4 objects and a variable length parameter
 list:");
    Console.WriteLine("4) {0}", String.Concat(o, o, o, o, o));

    Console.WriteLine("\nConcatenate a 3 element object array:");
    Console.WriteLine("5) {0}", String.Concat(objs));
    }
}
/*
This example produces the following output:
Concatenate 1, 2, and 3 objects:
1) -123
2) -123-123
3) -123-123-123

Concatenate 4 objects and a variable length parameter list:
4) -123-123-123-123-123

Concatenate a 3 element object array:
5) -123-456-789
*/
using namespace System;
int main()
{
   int i = -123;
   Object^ o = i;
   array<Object^>^objs = { -123, -456, -789};
   Console::WriteLine( "Concatenate 1, 2, and 3 objects:" );
   Console::WriteLine( "1) {0}", String::Concat( o ) );
   Console::WriteLine( "2) {0}", String::Concat( o, o ) );
   Console::WriteLine( "3) {0}", String::Concat( o, o, o ) );
   Console::WriteLine( "\nConcatenate 4 objects and a variable length parameter
 list:" );
   Console::WriteLine( "4) {0}", String::Concat( o, o, o, o, o ) );
   Console::WriteLine( "\nConcatenate a 3 element object array:" );
   Console::WriteLine( "5) {0}", String::Concat( objs ) );
}

/*
This example produces the following output:
Concatenate 1, 2, and 3 objects:
1) -123
2) -123-123
3) -123-123-123

Concatenate 4 objects and a variable length parameter list:
4) -123-123-123-123-123

Concatenate a 3 element object array:
5) -123-456-789
*/
import System.*;

class StringConcat5
{
    public static void main(String[]
 args)
    {
        int i = -123;
        Object o = (Int32)i;
        Object objs[] = new Object[] { (Int32)(-123), (Int32)(-456),
 
            (Int32)(-789) };

        Console.WriteLine("Concatenate 1, 2, and 3 objects:");
        Console.WriteLine("1) {0}", String.Concat(o));
        Console.WriteLine("2) {0}", String.Concat(o, o));
        Console.WriteLine("3) {0}", String.Concat(o, o, o));

        Console.WriteLine("\nConcatenate 4 objects and a variable length "
            + "parameter list:");
        Object objArr[] = { o, o, o, o, o };
        Console.WriteLine("4) {0}", String.Concat(objArr));

        Console.WriteLine("\nConcatenate a 3 element object array:");
        Console.WriteLine("5) {0}", String.Concat(objs));
    } //main
} //StringConcat5
/*
This example produces the following output:
Concatenate 1, 2, and 3 objects:
1) -123
2) -123-123
3) -123-123-123

Concatenate 4 objects and a variable length parameter list:
4) -123-123-123-123-123

Concatenate a 3 element object array:
5) -123-456-789
*/
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

String.Concat メソッド (Object[])

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

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

例外例外
例外種類条件

ArgumentNullException

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

解説解説
使用例使用例

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
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 {
}
using namespace System;

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

ref class Test2{};

int main()
{
   
   // create a group of objects
   Test1^ t1 = gcnew Test1;
   Test2^ t2 = gcnew Test2;
   int i = 16;
   String^ s = "Demonstration";
   
   // place the objects in an array
   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 ) );
}

import System.*;

public class ConcatTest
{
    public static void main(String[]
 args)
    {
        // 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, (Int32)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));
    } //main
} //ConcatTest

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

class Test2
{
} //Test2
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

String.Concat メソッド (Object, Object)

指定した 2 つオブジェクトString 形式連結します。

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

Public Shared Function Concat
 ( _
    arg0 As Object, _
    arg1 As Object _
) As String
Dim arg0 As Object
Dim arg1 As Object
Dim returnValue As String

returnValue = String.Concat(arg0, arg1)

パラメータ

arg0

第 1 の Object

arg1

第 2 の Object

戻り値
arg0arg1String 形式の値の連結結果

解説解説

Empty 文字列は、任意の null 引数代わりに使用されます。

どちらか引数配列参照である場合、このメソッドでは、その配列メンバではなく、その配列を表す文字形式連結します (たとえば "System.String[]")。

使用例使用例

Concat メソッドコード例次に示します

Imports System
Imports Microsoft.VisualBasic
 _

Class stringConcat5
   
   Public Shared Sub Main()
      Dim i As Integer =
 - 123
      Dim o As [Object] = i
      Dim objs() As [Object] = {- 123, - 456,
 - 789}
      
      Console.WriteLine("Concatenate 1, 2, and 3 objects:")
      Console.WriteLine("1) {0}", [String].Concat(o))
      Console.WriteLine("2) {0}", [String].Concat(o,
 o))
      Console.WriteLine("3) {0}", [String].Concat(o,
 o, o))
      
      Console.WriteLine(vbCrLf & "Concatenate 4 objects and
 a variable length parameter list:")
      Console.WriteLine("4) {0}", [String].Concat(o,
 o, o, o, o))
      
      Console.WriteLine(vbCrLf & "Concatenate a 3 element
 object array:")
      Console.WriteLine("5) {0}", [String].Concat(objs))
   End Sub 'Main
End Class 'stringConcat5
'
'This example produces the following output:
'Concatenate 1, 2, and 3 objects:
'1) -123
'2) -123-123
'3) -123-123-123
'
'Concatenate 4 objects and a variable length parameter list:
'4) -123-123-123-123-123
'
'Concatenate a 3 element object array:
'5) -123-456-789
'
using System;

class stringConcat5 {
    public static void Main()
 {
    int i = -123;
    Object o = i;
    Object[] objs = new Object[] {-123, -456, -789};

    Console.WriteLine("Concatenate 1, 2, and 3 objects:");
    Console.WriteLine("1) {0}", String.Concat(o));
    Console.WriteLine("2) {0}", String.Concat(o, o));
    Console.WriteLine("3) {0}", String.Concat(o, o, o));

    Console.WriteLine("\nConcatenate 4 objects and a variable length parameter
 list:");
    Console.WriteLine("4) {0}", String.Concat(o, o, o, o, o));

    Console.WriteLine("\nConcatenate a 3 element object array:");
    Console.WriteLine("5) {0}", String.Concat(objs));
    }
}
/*
This example produces the following output:
Concatenate 1, 2, and 3 objects:
1) -123
2) -123-123
3) -123-123-123

Concatenate 4 objects and a variable length parameter list:
4) -123-123-123-123-123

Concatenate a 3 element object array:
5) -123-456-789
*/
using namespace System;
int main()
{
   int i = -123;
   Object^ o = i;
   array<Object^>^objs = { -123, -456, -789};
   Console::WriteLine( "Concatenate 1, 2, and 3 objects:" );
   Console::WriteLine( "1) {0}", String::Concat( o ) );
   Console::WriteLine( "2) {0}", String::Concat( o, o ) );
   Console::WriteLine( "3) {0}", String::Concat( o, o, o ) );
   Console::WriteLine( "\nConcatenate 4 objects and a variable length parameter
 list:" );
   Console::WriteLine( "4) {0}", String::Concat( o, o, o, o, o ) );
   Console::WriteLine( "\nConcatenate a 3 element object array:" );
   Console::WriteLine( "5) {0}", String::Concat( objs ) );
}

/*
This example produces the following output:
Concatenate 1, 2, and 3 objects:
1) -123
2) -123-123
3) -123-123-123

Concatenate 4 objects and a variable length parameter list:
4) -123-123-123-123-123

Concatenate a 3 element object array:
5) -123-456-789
*/
import System.*;

class StringConcat5
{
    public static void main(String[]
 args)
    {
        int i = -123;
        Object o = (Int32)i;
        Object objs[] = new Object[] { (Int32)(-123), (Int32)(-456),
 
            (Int32)(-789) };

        Console.WriteLine("Concatenate 1, 2, and 3 objects:");
        Console.WriteLine("1) {0}", String.Concat(o));
        Console.WriteLine("2) {0}", String.Concat(o, o));
        Console.WriteLine("3) {0}", String.Concat(o, o, o));

        Console.WriteLine("\nConcatenate 4 objects and a variable length "
            + "parameter list:");
        Object objArr[] = { o, o, o, o, o };
        Console.WriteLine("4) {0}", String.Concat(objArr));

        Console.WriteLine("\nConcatenate a 3 element object array:");
        Console.WriteLine("5) {0}", String.Concat(objs));
    } //main
} //StringConcat5
/*
This example produces the following output:
Concatenate 1, 2, and 3 objects:
1) -123
2) -123-123
3) -123-123-123

Concatenate 4 objects and a variable length parameter list:
4) -123-123-123-123-123

Concatenate a 3 element object array:
5) -123-456-789
*/
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

String.Concat メソッド (Object)

指定したオブジェクトString 形式作成します

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

解説解説
使用例使用例

Concat メソッドコード例次に示します

Imports System
Imports Microsoft.VisualBasic
 _

Class stringConcat5
   
   Public Shared Sub Main()
      Dim i As Integer =
 - 123
      Dim o As [Object] = i
      Dim objs() As [Object] = {- 123, - 456,
 - 789}
      
      Console.WriteLine("Concatenate 1, 2, and 3 objects:")
      Console.WriteLine("1) {0}", [String].Concat(o))
      Console.WriteLine("2) {0}", [String].Concat(o,
 o))
      Console.WriteLine("3) {0}", [String].Concat(o,
 o, o))
      
      Console.WriteLine(vbCrLf & "Concatenate 4 objects and
 a variable length parameter list:")
      Console.WriteLine("4) {0}", [String].Concat(o,
 o, o, o, o))
      
      Console.WriteLine(vbCrLf & "Concatenate a 3 element
 object array:")
      Console.WriteLine("5) {0}", [String].Concat(objs))
   End Sub 'Main
End Class 'stringConcat5
'
'This example produces the following output:
'Concatenate 1, 2, and 3 objects:
'1) -123
'2) -123-123
'3) -123-123-123
'
'Concatenate 4 objects and a variable length parameter list:
'4) -123-123-123-123-123
'
'Concatenate a 3 element object array:
'5) -123-456-789
'
using System;

class stringConcat5 {
    public static void Main()
 {
    int i = -123;
    Object o = i;
    Object[] objs = new Object[] {-123, -456, -789};

    Console.WriteLine("Concatenate 1, 2, and 3 objects:");
    Console.WriteLine("1) {0}", String.Concat(o));
    Console.WriteLine("2) {0}", String.Concat(o, o));
    Console.WriteLine("3) {0}", String.Concat(o, o, o));

    Console.WriteLine("\nConcatenate 4 objects and a variable length parameter
 list:");
    Console.WriteLine("4) {0}", String.Concat(o, o, o, o, o));

    Console.WriteLine("\nConcatenate a 3 element object array:");
    Console.WriteLine("5) {0}", String.Concat(objs));
    }
}
/*
This example produces the following output:
Concatenate 1, 2, and 3 objects:
1) -123
2) -123-123
3) -123-123-123

Concatenate 4 objects and a variable length parameter list:
4) -123-123-123-123-123

Concatenate a 3 element object array:
5) -123-456-789
*/
using namespace System;
int main()
{
   int i = -123;
   Object^ o = i;
   array<Object^>^objs = { -123, -456, -789};
   Console::WriteLine( "Concatenate 1, 2, and 3 objects:" );
   Console::WriteLine( "1) {0}", String::Concat( o ) );
   Console::WriteLine( "2) {0}", String::Concat( o, o ) );
   Console::WriteLine( "3) {0}", String::Concat( o, o, o ) );
   Console::WriteLine( "\nConcatenate 4 objects and a variable length parameter
 list:" );
   Console::WriteLine( "4) {0}", String::Concat( o, o, o, o, o ) );
   Console::WriteLine( "\nConcatenate a 3 element object array:" );
   Console::WriteLine( "5) {0}", String::Concat( objs ) );
}

/*
This example produces the following output:
Concatenate 1, 2, and 3 objects:
1) -123
2) -123-123
3) -123-123-123

Concatenate 4 objects and a variable length parameter list:
4) -123-123-123-123-123

Concatenate a 3 element object array:
5) -123-456-789
*/
import System.*;

class StringConcat5
{
    public static void main(String[]
 args)
    {
        int i = -123;
        Object o = (Int32)i;
        Object objs[] = new Object[] { (Int32)(-123), (Int32)(-456),
 
            (Int32)(-789) };

        Console.WriteLine("Concatenate 1, 2, and 3 objects:");
        Console.WriteLine("1) {0}", String.Concat(o));
        Console.WriteLine("2) {0}", String.Concat(o, o));
        Console.WriteLine("3) {0}", String.Concat(o, o, o));

        Console.WriteLine("\nConcatenate 4 objects and a variable length "
            + "parameter list:");
        Object objArr[] = { o, o, o, o, o };
        Console.WriteLine("4) {0}", String.Concat(objArr));

        Console.WriteLine("\nConcatenate a 3 element object array:");
        Console.WriteLine("5) {0}", String.Concat(objs));
    } //main
} //StringConcat5
/*
This example produces the following output:
Concatenate 1, 2, and 3 objects:
1) -123
2) -123-123
3) -123-123-123

Concatenate 4 objects and a variable length parameter list:
4) -123-123-123-123-123

Concatenate a 3 element object array:
5) -123-456-789
*/
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

StringConcat プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ Delimiter  
参照参照

関連項目

StringConcat 構造体
System.Xml.Xsl.Runtime 名前空間

StringConcat メソッド


StringConcat メンバ


StringConcat 構造体

メモ : この構造体は、.NET Framework version 2.0新しく追加されたものです。

名前空間: System.Xml.Xsl.Runtime
アセンブリ: System.Data.SqlXml (system.data.sqlxml.dll 内)
構文構文

public struct StringConcat
public value class StringConcat
public final class StringConcat extends ValueType
JScript では、構造体使用できますが、新規に宣言することはできません。
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
StringConcat メンバ
System.Xml.Xsl.Runtime 名前空間



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

辞書ショートカット

すべての辞書の索引

「StringConcat」の関連用語

StringConcatのお隣キーワード
検索ランキング

   

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



StringConcatのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS