String.Concat String.Concat String.Concat String.Concat Method

定義

String の 1 つ以上のインスタンス、または String の 1 つ以上のインスタンスの Object 形式の値を連結します。Concatenates one or more instances of String, or the String representations of the values of one or more instances of Object.

オーバーロード

Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>) Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>) Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>) Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>)

3 つの指定された読み取り専用文字スパンの文字列形式を連結します。Concatenates the string representations of three specified read-only character spans.

Concat(String, String, String, String) Concat(String, String, String, String) Concat(String, String, String, String) Concat(String, String, String, String)

指定した 4 つの String インスタンスを連結します。Concatenates four specified instances of String.

Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>) Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>) Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>) Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>)

4 つの指定された読み取り専用文字スパンの文字列形式を連結します。Concatenates the string representations of four specified read-only character spans.

Concat(Object, Object, Object, Object) Concat(Object, Object, Object, Object) Concat(Object, Object, Object, Object) Concat(Object, Object, Object, Object)

4 つの指定したオブジェクトと、オプションの可変長パラメーター リストで指定した任意のオブジェクトの文字列表現を連結します。Concatenates the string representations of four specified objects and any objects specified in an optional variable length parameter list.

Concat(String, String, String) Concat(String, String, String) Concat(String, String, String) Concat(String, String, String)

String の指定した 3 つのインスタンスを連結します。Concatenates three specified instances of String.

Concat(String, String) Concat(String, String) Concat(String, String) Concat(String, String)

指定した 2 つの String インスタンスを連結します。Concatenates two specified instances of String.

Concat(Object, Object, Object) Concat(Object, Object, Object) Concat(Object, Object, Object) Concat(Object, Object, Object)

指定した 3 つのオブジェクトの文字列形式を連結します。Concatenates the string representations of three specified objects.

Concat(Object, Object) Concat(Object, Object) Concat(Object, Object) Concat(Object, Object)

指定した 2 つのオブジェクトの文字列形式を連結します。Concatenates the string representations of two specified objects.

Concat(String[]) Concat(String[]) Concat(String[]) Concat(String[])

指定した String 配列の要素を連結します。Concatenates the elements of a specified String array.

Concat(Object[]) Concat(Object[]) Concat(Object[]) Concat(Object[])

指定された Object 配列の要素の文字列表記を連結します。Concatenates the string representations of the elements in a specified Object array.

Concat(Object) Concat(Object) Concat(Object) Concat(Object)

指定されたオブジェクトの文字列形式を作成します。Creates the string representation of a specified object.

Concat(IEnumerable<String>) Concat(IEnumerable<String>) Concat(IEnumerable<String>) Concat(IEnumerable<String>)

IEnumerable<T> 型の構築された String コレクションのメンバーを連結します。Concatenates the members of a constructed IEnumerable<T> collection of type String.

Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>) Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>) Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>) Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>)

2 つの指定された読み取り専用文字スパンの文字列形式を連結します。Concatenates the string representations of two specified read-only character spans.

Concat<T>(IEnumerable<T>) Concat<T>(IEnumerable<T>) Concat<T>(IEnumerable<T>) Concat<T>(IEnumerable<T>)

IEnumerable<T> 実装のメンバーを連結します。Concatenates the members of an IEnumerable<T> implementation.

注釈

注意

言語の文字列+連結演算子 (in C#、 & + Visual Basic のなど) を使用して文字列を連結することもできます。You can also use your language's string concatenation operator, such as + in C#, or & and + in Visual Basic, to concatenate strings. どちらのコンパイラも、連結演算子をのString.Concatオーバーロードの1つの呼び出しに変換します。Both compilers translate the concatenation operator into a call to one of the overloads of String.Concat.

Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>) Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>) Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>) Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>)

3 つの指定された読み取り専用文字スパンの文字列形式を連結します。Concatenates the string representations of three specified read-only character spans.

public:
 static System::String ^ Concat(ReadOnlySpan<char> str0, ReadOnlySpan<char> str1, ReadOnlySpan<char> str2);
public static string Concat (ReadOnlySpan<char> str0, ReadOnlySpan<char> str1, ReadOnlySpan<char> str2);
static member Concat : ReadOnlySpan<char> * ReadOnlySpan<char> * ReadOnlySpan<char> -> string
Public Shared Function Concat (str0 As ReadOnlySpan(Of Char), str1 As ReadOnlySpan(Of Char), str2 As ReadOnlySpan(Of Char)) As String

パラメーター

str0
ReadOnlySpan<Char>

連結する最初の読み取り専用文字スパン。The first read-only character span to concatenate.

str1
ReadOnlySpan<Char>

連結する 2 番目の読み取り専用文字スパン。The second read-only character span to concatenate.

str2
ReadOnlySpan<Char>

連結する 3 番目の読み取り専用の文字スパン。The third read-only character span to concatenate.

戻り値

str0str1、および str2 の値の文字列形式を連結した結果。The concatenated string representations of the values of str0, str1 and str2.

Concat(String, String, String, String) Concat(String, String, String, String) Concat(String, String, String, String) Concat(String, String, String, String)

指定した 4 つの String インスタンスを連結します。Concatenates four specified instances of String.

public:
 static System::String ^ Concat(System::String ^ str0, System::String ^ str1, System::String ^ str2, System::String ^ str3);
public static string Concat (string str0, string str1, string str2, string str3);
static member Concat : string * string * string * string -> string
Public Shared Function Concat (str0 As String, str1 As String, str2 As String, str3 As String) As String

パラメーター

str0
String String String String

連結する最初の文字列。The first string to concatenate.

str1
String String String String

連結する 2 番目の文字列。The second string to concatenate.

str2
String String String String

連結する 3 番目の文字列。The third string to concatenate.

str3
String String String String

連結する 4 番目の文字列。The fourth string to concatenate.

戻り値

str0str1str2、および str3 の連結。The concatenation of str0, str1, str2, and str3.

次の例では、4文字の単語の配列を定義し、それらの文字をスクランブルするために文字列配列に格納します。The following example defines an array of four-letter words and stores their individual letters to a string array in order to scramble them. 次に、メソッドConcat(String, String, String, String)を呼び出して、スクランブルされた単語を再アセンブルします。It then calls the Concat(String, String, String, String) method to reassemble the scrambled words.

using System;
using System.Collections;

public class Example
{
   public static void Main()
   {
      const int WORD_SIZE = 4;
      
      // Define some 4-letter words to be scrambled.
      string[] words = { "home", "food", "game", "rest" };
      // Define two arrays equal to the number of letters in each word.
      double[] keys = new double[WORD_SIZE];
      string[] letters = new string[WORD_SIZE];
      // Initialize the random number generator.
      Random rnd = new Random();
      
      // Scramble each word.
      foreach (string word in words)
      {
         for (int ctr = 0; ctr < word.Length; ctr++)
         {
            // Populate the array of keys with random numbers.
            keys[ctr] = rnd.NextDouble();
            // Assign a letter to the array of letters.
            letters[ctr] = word[ctr].ToString();
         }   
         // Sort the array. 
         Array.Sort(keys, letters, 0, WORD_SIZE, Comparer.Default);      
         // Display the scrambled word.
         string scrambledWord = String.Concat(letters[0], letters[1], 
                                              letters[2], letters[3]);
         Console.WriteLine("{0} --> {1}", word, scrambledWord);
      } 
   }
}
// The example displays output like the following:
//       home --> mheo
//       food --> oodf
//       game --> aemg
//       rest --> trse
Imports System.Collections

Module Example
   Public Sub Main()
      Const WORD_SIZE As Integer = 4
      
      ' Define some 4-letter words to be scrambled.
      Dim words() As String = { "home", "food", "game", "rest" }
      ' Define two arrays equal to the number of letters in each word.
      Dim keys(WORD_SIZE) As Double
      Dim letters(WORD_SIZE) As String
      ' Initialize the random number generator.
      Dim rnd As New Random()
      
      ' Scramble each word.
      For Each word As String In words
         For ctr As Integer = 0 To word.Length - 1
            ' Populate the array of keys with random numbers.
            keys(ctr) = rnd.NextDouble()
            ' Assign a letter to the array of letters.
            letters(ctr) = word.Chars(ctr)
         Next   
         ' Sort the array. 
         Array.Sort(keys, letters, 0, WORD_SIZE, Comparer.Default)      
         ' Display the scrambled word.
         Dim scrambledWord As String = String.Concat(letters(0), letters(1), _
                                                     letters(2), letters(3))
         Console.WriteLine("{0} --> {1}", word, scrambledWord)
      Next 
   End Sub
End Module 
' The example displays output like the following:
'       home --> mheo
'       food --> oodf
'       game --> aemg
'       rest --> trse

注釈

str0メソッドはstr1 str3、、、、およびを連結します。区切り記号は追加されません。 str2The method concatenates str0, str1, str2, and str3; it does not add any delimiters.

こちらもご覧ください

Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>) Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>) Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>) Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>, ReadOnlySpan<Char>)

4 つの指定された読み取り専用文字スパンの文字列形式を連結します。Concatenates the string representations of four specified read-only character spans.

public:
 static System::String ^ Concat(ReadOnlySpan<char> str0, ReadOnlySpan<char> str1, ReadOnlySpan<char> str2, ReadOnlySpan<char> str3);
public static string Concat (ReadOnlySpan<char> str0, ReadOnlySpan<char> str1, ReadOnlySpan<char> str2, ReadOnlySpan<char> str3);
static member Concat : ReadOnlySpan<char> * ReadOnlySpan<char> * ReadOnlySpan<char> * ReadOnlySpan<char> -> string
Public Shared Function Concat (str0 As ReadOnlySpan(Of Char), str1 As ReadOnlySpan(Of Char), str2 As ReadOnlySpan(Of Char), str3 As ReadOnlySpan(Of Char)) As String

パラメーター

str0
ReadOnlySpan<Char>

連結する最初の読み取り専用文字スパン。The first read-only character span to concatenate.

str1
ReadOnlySpan<Char>

連結する 2 番目の読み取り専用文字スパン。The second read-only character span to concatenate.

str2
ReadOnlySpan<Char>

連結する 3 番目の読み取り専用の文字スパン。The third read-only character span to concatenate.

str3
ReadOnlySpan<Char>

連結する 4 番目の読み取り専用の文字スパン。The fourth read-only character span to concatenate.

戻り値

str0str1str2、および str3 の値の文字列形式を連結した結果。The concatenated string representations of the values of str0, str1, str2 and str3.

Concat(Object, Object, Object, Object) Concat(Object, Object, Object, Object) Concat(Object, Object, Object, Object) Concat(Object, Object, Object, Object)

重要

この API は CLS 準拠ではありません。

4 つの指定したオブジェクトと、オプションの可変長パラメーター リストで指定した任意のオブジェクトの文字列表現を連結します。Concatenates the string representations of four specified objects and any objects specified in an optional variable length parameter list.

public:
 static System::String ^ Concat(System::Object ^ arg0, System::Object ^ arg1, System::Object ^ arg2, System::Object ^ arg3);
[System.CLSCompliant(false)]
public static string Concat (object arg0, object arg1, object arg2, object arg3);
static member Concat : obj * obj * obj * obj -> string
Public Shared Function Concat (arg0 As Object, arg1 As Object, arg2 As Object, arg3 As Object) As String

パラメーター

arg0
Object Object Object Object

連結する最初のオブジェクト。The first object to concatenate.

arg1
Object Object Object Object

連結する 2 番目のオブジェクト。The second object to concatenate.

arg2
Object Object Object Object

連結する 3 番目のオブジェクト。The third object to concatenate.

arg3
Object Object Object Object

連結する 4 番目のオブジェクト。The fourth object to concatenate.

戻り値

パラメーター リスト内の各値の文字列を連結した結果。The concatenated string representation of each value in the parameter list.

次の例は、 Concat(Object, Object, Object, Object)メソッドを使用して、変数パラメーターの一覧を連結する方法を示しています。The following example illustrates the use of the Concat(Object, Object, Object, Object) method to concatenate a list of variable parameters. この場合、メソッドは9個のパラメーターを使用して呼び出されます。In this case, the method is called with nine parameters.

using System;
using System.Collections;

public class Example
{
   public static void Main()
   {
      const int WORD_SIZE = 4;
      
      // Define some 4-letter words to be scrambled.
      string[] words = { "home", "food", "game", "rest" };
      // Define two arrays equal to the number of letters in each word.
      double[] keys = new double[WORD_SIZE];
      string[] letters = new string[WORD_SIZE];
      // Initialize the random number generator.
      Random rnd = new Random();
      
      // Scramble each word.
      foreach (string word in words)
      {
         for (int ctr = 0; ctr < word.Length; ctr++)
         {
            // Populate the array of keys with random numbers.
            keys[ctr] = rnd.NextDouble();
            // Assign a letter to the array of letters.
            letters[ctr] = word[ctr].ToString();
         }   
         // Sort the array. 
         Array.Sort(keys, letters, 0, WORD_SIZE, Comparer.Default);      
         // Display the scrambled word.
         string scrambledWord = String.Concat(letters[0], letters[1], 
                                              letters[2], letters[3]);
         Console.WriteLine("{0} --> {1}", word, scrambledWord);
      } 
   }
}
// The example displays output like the following:
//       home --> mheo
//       food --> oodf
//       game --> aemg
//       rest --> trse
Imports System.Collections

Module Example
   Public Sub Main()
      Const WORD_SIZE As Integer = 4
      
      ' Define some 4-letter words to be scrambled.
      Dim words() As String = { "home", "food", "game", "rest" }
      ' Define two arrays equal to the number of letters in each word.
      Dim keys(WORD_SIZE) As Double
      Dim letters(WORD_SIZE) As String
      ' Initialize the random number generator.
      Dim rnd As New Random()
      
      ' Scramble each word.
      For Each word As String In words
         For ctr As Integer = 0 To word.Length - 1
            ' Populate the array of keys with random numbers.
            keys(ctr) = rnd.NextDouble()
            ' Assign a letter to the array of letters.
            letters(ctr) = word.Chars(ctr)
         Next   
         ' Sort the array. 
         Array.Sort(keys, letters, 0, WORD_SIZE, Comparer.Default)      
         ' Display the scrambled word.
         Dim scrambledWord As String = String.Concat(letters(0), letters(1), _
                                                     letters(2), letters(3))
         Console.WriteLine("{0} --> {1}", word, scrambledWord)
      Next 
   End Sub
End Module 
' The example displays output like the following:
'       home --> mheo
'       food --> oodf
'       game --> aemg
'       rest --> trse

注釈

注意

この API は、CLS に準拠していません。This API is not CLS-compliant. CLS 準拠の代わりとして String.Concat(Object[]) を使用できます。The CLS-compliant alternative is String.Concat(Object[]). およびC# Visual Basic コンパイラは、このメソッドへの呼び出しをの呼び出しString.Concat(Object[])として自動的に解決します。The C# and Visual Basic compilers automatically resolve a call to this method as a call to String.Concat(Object[]).

メソッドは、パラメーターなしToStringのメソッドを呼び出すことによって、パラメーターリスト内の各オブジェクトを連結します。区切り記号は追加されません。The method concatenates each object in the parameter list by calling its parameterless ToString method; it does not add any delimiters.

String.Emptyは、null 引数の代わりに使用されます。String.Empty is used in place of any null argument.

注意

Concatメソッドの最後のパラメーターは、連結する1つ以上の追加オブジェクトのコンマ区切りのリストです (省略可能)。The last parameter of the Concat method is an optional comma-delimited list of one or more additional objects to concatenate.

注意 (呼び出し元)

このメソッドは、 varargキーワードでマークされています。これは、可変個のパラメーターをサポートしていることを意味します。This method is marked with the vararg keyword, which means that it supports a variable number of parameters. メソッドはビジュアルC++から呼び出すことができますが、または Visual Basic C#コードから呼び出すことはできません。The method can be called from Visual C++, but it cannot be called from C# or Visual Basic code. およびC# Visual Basic コンパイラは、の呼び出しConcat(Object, Object, Object, Object) Concat(Object[])としての呼び出しを解決します。The C# and Visual Basic compilers resolve calls to Concat(Object, Object, Object, Object) as calls to Concat(Object[]).

Concat(String, String, String) Concat(String, String, String) Concat(String, String, String) Concat(String, String, String)

String の指定した 3 つのインスタンスを連結します。Concatenates three specified instances of String.

public:
 static System::String ^ Concat(System::String ^ str0, System::String ^ str1, System::String ^ str2);
public static string Concat (string str0, string str1, string str2);
static member Concat : string * string * string -> string
Public Shared Function Concat (str0 As String, str1 As String, str2 As String) As String

パラメーター

str0
String String String String

連結する最初の文字列。The first string to concatenate.

str1
String String String String

連結する 2 番目の文字列。The second string to concatenate.

str2
String String String String

連結する 3 番目の文字列。The third string to concatenate.

戻り値

str0str1、および str2 の連結。The concatenation of str0, str1, and str2.

次の例ではConcat 、メソッドを使用して、3つの文字列を連結し、結果を表示します。The following example uses the Concat method to concatenate three strings and displays the result.

using namespace System;

void main()
{
   String^ s1 = "We went to a bookstore, ";
   String^ s2 = "a movie, ";
   String^ s3 = "and a restaurant.";

   String^ s = String::Concat(s1, s2, s3);
   Console::WriteLine(s);
}
// The example displays the following output:
//      We went to a bookstore, a movie, and a restaurant. 
using System;

public class Example
{
   public static void Main()
   {
      String s1 = "We went to a bookstore, ";
      String s2 = "a movie, ";
      String s3 = "and a restaurant.";

      var s = String.Concat(s1, s2, s3);
      Console.WriteLine(s);
   }
}
// The example displays the following output:
//      We went to a bookstore, a movie, and a restaurant. 
Public Module Example
   Public Sub Main()
      Dim s1 As String = "We went to a bookstore, "
      Dim s2 As String = "a movie, "
      Dim s3 As String = "and a restaurant."

      Dim s = String.Concat(s1, s2, s3)
      Console.WriteLine(s)
   End Sub
End Module
' The example displays the following output:
'      We went to a bookstore, a movie, and a restaurant. 

注釈

メソッドは、 str0 str1、、およびstr2を連結します。区切り記号は追加されません。The method concatenates str0, str1, and str2; it does not add any delimiters.

こちらもご覧ください

Concat(String, String) Concat(String, String) Concat(String, String) Concat(String, String)

指定した 2 つの String インスタンスを連結します。Concatenates two specified instances of String.

public:
 static System::String ^ Concat(System::String ^ str0, System::String ^ str1);
public static string Concat (string str0, string str1);
static member Concat : string * string -> string
Public Shared Function Concat (str0 As String, str1 As String) As String

パラメーター

str0
String String String String

連結する最初の文字列。The first string to concatenate.

str1
String String String String

連結する 2 番目の文字列。The second string to concatenate.

戻り値

str0str1 の連結。The concatenation of str0 and str1.

次の例では、ユーザーの姓、ミドルネーム、および姓を連結しています。The following example concatenates a person's first, middle, and last name.

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 ) );
}
// The example displays the following output:
//        Welcome to this page, 'Simon Jake Harrows'!
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 ) );
    }
}
// The example displays the following output:
//        Welcome to this page, 'Simon Jake Harrows'!
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, 
        ' we 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
End Class
' The example displays the following output:
'       Welcome to this page, 'Simon Jake Harrows'!

注釈

メソッドはとstr0str1連結します。区切り記号は追加されません。The method concatenates str0 and str1; it does not add any delimiters.

Null 引数の代わりに文字列を使用します。EmptyAn Empty string is used in place of any null argument.

こちらもご覧ください

Concat(Object, Object, Object) Concat(Object, Object, Object) Concat(Object, Object, Object) Concat(Object, Object, Object)

指定した 3 つのオブジェクトの文字列形式を連結します。Concatenates the string representations of three specified objects.

public:
 static System::String ^ Concat(System::Object ^ arg0, System::Object ^ arg1, System::Object ^ arg2);
public static string Concat (object arg0, object arg1, object arg2);
static member Concat : obj * obj * obj -> string
Public Shared Function Concat (arg0 As Object, arg1 As Object, arg2 As Object) As String

パラメーター

arg0
Object Object Object Object

連結する最初のオブジェクト。The first object to concatenate.

arg1
Object Object Object Object

連結する 2 番目のオブジェクト。The second object to concatenate.

arg2
Object Object Object Object

連結する 3 番目のオブジェクト。The third object to concatenate.

戻り値

arg0arg1 および arg2 の値の文字列形式を連結した結果。The concatenated string representations of the values of arg0, arg1, and arg2.

メソッドのConcat例を次に示します。The following example demonstrates the Concat method.

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));
   Console::WriteLine("5) {0}", String::Concat( o, o, o, o, o));
   Console::WriteLine("\nConcatenate a 3-element object array:");
   Console::WriteLine("6) {0}", String::Concat(objs));
}
// The example displays 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
//    5) -123-123-123-123-123
//    
//    Concatenate a 3-element object array:
//    6) -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));
    Console.WriteLine("5) {0}", String.Concat(o, o, o, o, o));

    Console.WriteLine("\nConcatenate a 3-element object array:");
    Console.WriteLine("6) {0}", String.Concat(objs));
    }
}
// The example displays 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
//    5) -123-123-123-123-123
//    
//    Concatenate a 3-element object array:
//    6) -123-456-789
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))
      Console.WriteLine("5) {0}", String.Concat(o, o, o, o, o))
      
      Console.WriteLine(vbCrLf & "Concatenate a 3-element object array:")
      Console.WriteLine("6) {0}", [String].Concat(objs))
   End Sub
End Class
'The example displays 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
'    5) -123-123-123-123-123
'         
'    Concatenate a 3-element object array:
'    6) -123-456-789

注釈

メソッドは、 arg0 arg1各オブジェクトのarg2パラメーターなしToStringのメソッドを呼び出すことによって、、およびを連結します。区切り記号は追加されません。The method concatenates arg0, arg1, and arg2 by calling the parameterless ToString method of each object; it does not add any delimiters.

String.Emptyは、null 引数の代わりに使用されます。String.Empty is used in place of any null argument.

こちらもご覧ください

Concat(Object, Object) Concat(Object, Object) Concat(Object, Object) Concat(Object, Object)

指定した 2 つのオブジェクトの文字列形式を連結します。Concatenates the string representations of two specified objects.

public:
 static System::String ^ Concat(System::Object ^ arg0, System::Object ^ arg1);
public static string Concat (object arg0, object arg1);
static member Concat : obj * obj -> string
Public Shared Function Concat (arg0 As Object, arg1 As Object) As String

パラメーター

arg0
Object Object Object Object

連結する最初のオブジェクト。The first object to concatenate.

arg1
Object Object Object Object

連結する 2 番目のオブジェクト。The second object to concatenate.

戻り値

arg0 および arg1 の値の文字列形式を連結した結果。The concatenated string representations of the values of arg0 and arg1.

メソッドのConcat例を次に示します。The following example demonstrates the Concat method.

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));
   Console::WriteLine("5) {0}", String::Concat( o, o, o, o, o));
   Console::WriteLine("\nConcatenate a 3-element object array:");
   Console::WriteLine("6) {0}", String::Concat(objs));
}
// The example displays 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
//    5) -123-123-123-123-123
//    
//    Concatenate a 3-element object array:
//    6) -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));
    Console.WriteLine("5) {0}", String.Concat(o, o, o, o, o));

    Console.WriteLine("\nConcatenate a 3-element object array:");
    Console.WriteLine("6) {0}", String.Concat(objs));
    }
}
// The example displays 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
//    5) -123-123-123-123-123
//    
//    Concatenate a 3-element object array:
//    6) -123-456-789
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))
      Console.WriteLine("5) {0}", String.Concat(o, o, o, o, o))
      
      Console.WriteLine(vbCrLf & "Concatenate a 3-element object array:")
      Console.WriteLine("6) {0}", [String].Concat(objs))
   End Sub
End Class
'The example displays 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
'    5) -123-123-123-123-123
'         
'    Concatenate a 3-element object array:
'    6) -123-456-789

注釈

メソッドは、 arg0arg1のパラメーターなしToString arg0arg1メソッドを呼び出すことによってとを連結します。区切り記号は追加されません。The method concatenates arg0 and arg1 by calling the parameterless ToString method of arg0 and arg1; it does not add any delimiters.

String.Emptyは、null 引数の代わりに使用されます。String.Empty is used in place of any null argument.

場合か、引数の配列参照は、メソッドは、そのメンバー (たとえば、"System.String[]") 代わりに、その配列を表す文字列を連結します。If either of the arguments is an array reference, the method concatenates a string representing that array, instead of its members (for example, "System.String[]").

こちらもご覧ください

Concat(String[]) Concat(String[]) Concat(String[]) Concat(String[])

重要

この API は CLS 準拠ではありません。

指定した String 配列の要素を連結します。Concatenates the elements of a specified String array.

public:
 static System::String ^ Concat(... cli::array <System::String ^> ^ values);
[System.CLSCompliant(false)]
public static string Concat (params string[] values);
static member Concat : string[] -> string
Public Shared Function Concat (ParamArray values As String()) As String

パラメーター

values
String[]

文字列インスタンスの配列。An array of string instances.

戻り値

連結された values の要素。The concatenated elements of values.

例外

メモリが不足しています。Out of memory.

次の例では、 Concat String配列を使用してメソッドを使用する方法を示します。The following example demonstrates the use of the Concat method with a String array.

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));
}
// The example displays the following output:
//       hello and welcome to this demo!
//       and demo! hello this to welcome
using System;

public class Example
{
    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));
    }
}
// The example displays the following output:
//       hello and welcome to this demo!
//       and demo! hello this to welcome
Public Class Example
    Public Shared Sub Main()
        ' Make an array of strings. Note that we have included spaces.
        Dim s As String() = { "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))
    End Sub
End Class
' The example displays the following output:
'       hello and welcome to this demo!
'       and demo! hello this to welcome

注釈

メソッドは、内の各valuesオブジェクトを連結します。区切り記号は追加されません。The method concatenates each object in values; it does not add any delimiters.

Empty文字列は、配列内の null オブジェクトの代わりに使用されます。An Empty string is used in place of any null object in the array.

こちらもご覧ください

Concat(Object[]) Concat(Object[]) Concat(Object[]) Concat(Object[])

指定された Object 配列の要素の文字列表記を連結します。Concatenates the string representations of the elements in a specified Object array.

public:
 static System::String ^ Concat(... cli::array <System::Object ^> ^ args);
public static string Concat (params object[] args);
static member Concat : obj[] -> string
Public Shared Function Concat (ParamArray args As Object()) As String

パラメーター

args
Object[]

連結する要素を格納しているオブジェクト配列。An object array that contains the elements to concatenate.

戻り値

args の各要素の値を連結した文字列表記。The concatenated string representations of the values of the elements in args.

例外

メモリが不足しています。Out of memory.

次の例では、 Concat Object配列を使用してメソッドを使用する方法を示します。The following example demonstrates the use of the Concat method with an Object array.

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 of each of the objects is called.
        Console.WriteLine(string.Concat(o));
    }
}

// Create two empty test classes.
class Test1 {
}

class Test2 {
}
// The example displays the following output:
//       Test116Test2Demonstration
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
End Class


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

Class Test2
End Class

注釈

メソッドは、そのオブジェクトのargsパラメーターなしToStringのメソッドを呼び出すことによって、内の各オブジェクトを連結します。区切り記号は追加されません。The method concatenates each object in args by calling the parameterless ToString method of that object; it does not add any delimiters.

String.Emptyは、配列内の null オブジェクトの代わりに使用されます。String.Empty is used in place of any null object in the array.

注意 (呼び出し元)

このメソッドは、コードにC++よって呼び出されません。This method is not called by C++ code. コンパイラC++は、の呼び出しConcat Concat(Object, Object, Object, Object)として、4つ以上のオブジェクトパラメーターを持つの呼び出しを解決します。The C++ compiler resolves calls to Concat that have four or more object parameters as a call to Concat(Object, Object, Object, Object).

こちらもご覧ください

Concat(Object) Concat(Object) Concat(Object) Concat(Object)

指定されたオブジェクトの文字列形式を作成します。Creates the string representation of a specified object.

public:
 static System::String ^ Concat(System::Object ^ arg0);
public static string Concat (object arg0);
static member Concat : obj -> string
Public Shared Function Concat (arg0 As Object) As String

パラメーター

arg0
Object Object Object Object

表現するオブジェクトまたは nullThe object to represent, or null.

戻り値

arg0 の値の文字列形式。Emptyarg0 の場合は nullThe string representation of the value of arg0, or Empty if arg0 is null.

メソッドのConcat例を次に示します。The following example demonstrates the Concat method.

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));
   Console::WriteLine("5) {0}", String::Concat( o, o, o, o, o));
   Console::WriteLine("\nConcatenate a 3-element object array:");
   Console::WriteLine("6) {0}", String::Concat(objs));
}
// The example displays 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
//    5) -123-123-123-123-123
//    
//    Concatenate a 3-element object array:
//    6) -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));
    Console.WriteLine("5) {0}", String.Concat(o, o, o, o, o));

    Console.WriteLine("\nConcatenate a 3-element object array:");
    Console.WriteLine("6) {0}", String.Concat(objs));
    }
}
// The example displays 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
//    5) -123-123-123-123-123
//    
//    Concatenate a 3-element object array:
//    6) -123-456-789
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))
      Console.WriteLine("5) {0}", String.Concat(o, o, o, o, o))
      
      Console.WriteLine(vbCrLf & "Concatenate a 3-element object array:")
      Console.WriteLine("6) {0}", [String].Concat(objs))
   End Sub
End Class
'The example displays 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
'    5) -123-123-123-123-123
'         
'    Concatenate a 3-element object array:
'    6) -123-456-789

注釈

メソッドConcat(Object)は、 arg0パラメーターなしToStringのメソッドを呼び出すことによって、文字列としてを表します。The Concat(Object) method represents arg0 as a string by calling its parameterless ToString method.

こちらもご覧ください

Concat(IEnumerable<String>) Concat(IEnumerable<String>) Concat(IEnumerable<String>) Concat(IEnumerable<String>)

IEnumerable<T> 型の構築された String コレクションのメンバーを連結します。Concatenates the members of a constructed IEnumerable<T> collection of type String.

public:
 static System::String ^ Concat(System::Collections::Generic::IEnumerable<System::String ^> ^ values);
[System.Runtime.InteropServices.ComVisible(false)]
public static string Concat (System.Collections.Generic.IEnumerable<string> values);
static member Concat : seq<string> -> string
Public Shared Function Concat (values As IEnumerable(Of String)) As String

パラメーター

values
IEnumerable<String>

IEnumerable<T> を実装し、ジェネリック型引数が String であるコレクション オブジェクト。A collection object that implements IEnumerable<T> and whose generic type argument is String.

戻り値

values 内の文字列の連結結果。または、values が空の IEnumerable(Of String) である場合は EmptyThe concatenated strings in values, or Empty if values is an empty IEnumerable(Of String).

例外

次の例では、ありアルゴリズムのエラトステネスを使用して、100以下の素数を計算します。The following example uses the Sieve of Eratosthenes algorithm to calculate the prime numbers that are less than or equal to 100. 結果を型List<T> Stringのオブジェクトに代入し、次にConcat(IEnumerable<String>)メソッドに渡します。It assigns the result to a List<T> object of type String, which it then passes to the Concat(IEnumerable<String>) method.

using System;
using System.Collections.Generic;

public class Example
{
   public static void Main()
   {
      int maxPrime = 100;
      IEnumerable<String> primeList = GetPrimes(maxPrime);
      Console.WriteLine("Primes less than {0}:", maxPrime);
      Console.WriteLine("   {0}", String.Concat(primeList));
   }

   private static IEnumerable<String> GetPrimes(int maxPrime)
   {
      Array values = Array.CreateInstance(typeof(int), 
                              new int[] { maxPrime - 1}, new int[] { 2 }); 
      // Use Sieve of Erathsthenes to determine prime numbers.
      for (int ctr = values.GetLowerBound(0); ctr <= (int) Math.Ceiling(Math.Sqrt(values.GetUpperBound(0))); ctr++)
      {
                           
         if ((int) values.GetValue(ctr) == 1) continue;
         
         for (int multiplier = ctr; multiplier <=  maxPrime / 2; multiplier++)
            if (ctr * multiplier <= maxPrime)
               values.SetValue(1, ctr * multiplier);
      }      
      
      List<String> primes = new List<String>();
      for (int ctr = values.GetLowerBound(0); ctr <= values.GetUpperBound(0); ctr++)
         if ((int) values.GetValue(ctr) == 0) 
            primes.Add(ctr.ToString() + " ");
      return primes;
   }   
}
// The example displays the following output:
//    Primes less than 100:
//       2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
Imports System.Collections.Generic

Module Example
   Public Sub Main()
      Dim maxPrime As Integer = 100
      Dim primeList As IEnumerable(Of String) = GetPrimes(maxPrime)
      Console.WriteLine("Primes less than {0}:", maxPrime)
      Console.WriteLine("   {0}", String.Concat(primeList))
   End Sub
   
   Private Function GetPrimes(maxPrime As Integer) As IEnumerable(Of String)
      Dim values As Array = Array.CreateInstance(GetType(Integer), _
                              New Integer() { maxPrime - 1}, New Integer(){ 2 }) 
      ' Use Sieve of Erathsthenes to determine prime numbers.
      For ctr As Integer = values.GetLowerBound(0) To _
                           CInt(Math.Ceiling(Math.Sqrt(values.GetUpperBound(0))))
         If CInt(values.GetValue(ctr)) = 1 Then Continue For
         
         For multiplier As Integer = ctr To maxPrime \ 2
            If ctr * multiplier <= maxPrime Then values.SetValue(1, ctr * multiplier)
         Next   
      Next      
      
      Dim primes As New List(Of String)
      For ctr As Integer = values.GetLowerBound(0) To values.GetUpperBound(0)
         If CInt(values.GetValue(ctr)) = 0 Then primes.Add(ctr.ToString() + " ")
      Next            
      Return primes
   End Function   
End Module
' The example displays the following output:
'    Primes less than 100:
'       2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

注釈

メソッドは、内の各valuesオブジェクトを連結します。区切り記号は追加されません。The method concatenates each object in values; it does not add any delimiters. values各メンバーの間に区切り記号を指定するJoin(String, IEnumerable<String>)には、メソッドを呼び出します。To specify a delimiter between each member of values, call the Join(String, IEnumerable<String>) method.

文字列は、内valuesの null 要素の代わりに使用されます。 EmptyAn Empty string is used in place of any null element in values.

If values である場合は IEnumerable(Of String)の場合、メソッドは String.Emptyです。If values is an empty IEnumerable(Of String), the method returns String.Empty. ArgumentNullExceptionvalues の場合、メソッドは例外をnullスローします。If values is null, the method throws an ArgumentNullException exception.

Concat(IEnumerable<String>)は、要素を最初に文字列配列に変換せずIEnumerable(Of String)に、コレクション内の各要素を連結できる便利なメソッドです。Concat(IEnumerable<String>) is a convenience method that lets you concatenate each element in an IEnumerable(Of String) collection without first converting the elements to a string array. これは、統合言語クエリ (LINQ) クエリ式で特に便利です。It is particularly useful with Language-Integrated Query (LINQ) query expressions. 次の例ではList(Of String) 、アルファベットの大文字または小文字を含むオブジェクトを、特定の文字以上の文字 (例では "M") を選択するラムダ式に渡します。The following example passes a List(Of String) object that contains either the uppercase or lowercase letters of the alphabet to a lambda expression that selects letters that are equal to or greater than a particular letter (which, in the example, is "M"). メソッドによって返されるIEnumerable(Of String)コレクションは、結果を1つの文字列として表示するためにメソッドに渡されます。Concat(IEnumerable<String>) Enumerable.WhereThe IEnumerable(Of String) collection that is returned by the Enumerable.Where method is passed to the Concat(IEnumerable<String>) method to display the result as a single string.

using System;
using System.Collections.Generic;
using System.Linq;

public class Example
{
   public static void Main()
   {
      string output = String.Concat( GetAlphabet(true).Where( letter => 
                      letter.CompareTo("M") >= 0));
      Console.WriteLine(output);  
   }

   private static List<string> GetAlphabet(bool upper)
   {
      List<string> alphabet = new List<string>();
      int charValue = upper ? 65 : 97;
      for (int ctr = 0; ctr <= 25; ctr++)
         alphabet.Add(Convert.ToChar(charValue + ctr).ToString());
      return alphabet; 
   }
}
// The example displays the following output:
//      MNOPQRSTUVWXYZ
Imports System.Collections.Generic
Imports System.Linq

Module modMain
   Public Sub Main()
      Dim output As String = String.Concat(GetAlphabet(true).Where(Function(letter) _
                                                         letter >= "M"))
        
      Console.WriteLine(output)                                     
   End Sub
   
   Private Function GetAlphabet(upper As Boolean) As List(Of String)
      Dim alphabet As New List(Of String)
      Dim charValue As Integer = CInt(IIf(upper, 65, 97))
      For ctr As Integer = 0 To 25
         alphabet.Add(ChrW(charValue + ctr).ToString())
      Next
      Return alphabet 
   End Function
End Module
' The example displays the following output:
'       MNOPQRSTUVWXYZ

Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>) Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>) Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>) Concat(ReadOnlySpan<Char>, ReadOnlySpan<Char>)

2 つの指定された読み取り専用文字スパンの文字列形式を連結します。Concatenates the string representations of two specified read-only character spans.

public:
 static System::String ^ Concat(ReadOnlySpan<char> str0, ReadOnlySpan<char> str1);
public static string Concat (ReadOnlySpan<char> str0, ReadOnlySpan<char> str1);
static member Concat : ReadOnlySpan<char> * ReadOnlySpan<char> -> string
Public Shared Function Concat (str0 As ReadOnlySpan(Of Char), str1 As ReadOnlySpan(Of Char)) As String

パラメーター

str0
ReadOnlySpan<Char>

連結する最初の読み取り専用文字スパン。The first read-only character span to concatenate.

str1
ReadOnlySpan<Char>

連結する 2 番目の読み取り専用文字スパン。The second read-only character span to concatenate.

戻り値

str0 および str1 の値の文字列形式を連結した結果。The concatenated string representations of the values of str0 and str1.

Concat<T>(IEnumerable<T>) Concat<T>(IEnumerable<T>) Concat<T>(IEnumerable<T>) Concat<T>(IEnumerable<T>)

IEnumerable<T> 実装のメンバーを連結します。Concatenates the members of an IEnumerable<T> implementation.

public:
generic <typename T>
 static System::String ^ Concat(System::Collections::Generic::IEnumerable<T> ^ values);
[System.Runtime.InteropServices.ComVisible(false)]
public static string Concat<T> (System.Collections.Generic.IEnumerable<T> values);
static member Concat : seq<'T> -> string
Public Shared Function Concat(Of T) (values As IEnumerable(Of T)) As String

型パラメーター

T

values のメンバーの型。The type of the members of values.

パラメーター

values
IEnumerable<T> IEnumerable<T> IEnumerable<T> IEnumerable<T>

IEnumerable<T> インターフェイスを実装するコレクション オブジェクト。A collection object that implements the IEnumerable<T> interface.

戻り値

values 内のメンバーの連結結果。The concatenated members in values.

例外

次の例では、動物Animalの名前とそれが属する順序を含む非常に単純なクラスを定義しています。The following example defines a very simple Animal class that contains the name of an animal and the order to which it belongs. 次に、複数List<T>Animalオブジェクトを格納するオブジェクトを定義します。It then defines a List<T> object to contain a number of Animal objects. 拡張Enumerable.Whereメソッドは、 Orderプロパティが "げっ歯類Animal " と等しいオブジェクトを抽出するために呼び出されます。The Enumerable.Where extension method is called to extract the Animal objects whose Order property equals "Rodent". 結果はConcat<T>(IEnumerable<T>)メソッドに渡され、コンソールに表示されます。The result is passed to the Concat<T>(IEnumerable<T>) method and displayed to the console.

using System;
using System.Collections.Generic;
using System.Linq;

public class Animal
{
   public string Kind;
   public string Order;
   
   public Animal(string kind, string order)
   {
      this.Kind = kind;
      this.Order = order;
   }
   
   public override string ToString()
   {
      return this.Kind;
   }
}

public class Example
{
   public static void Main()
   {
      List<Animal> animals = new List<Animal>();
      animals.Add(new Animal("Squirrel", "Rodent"));
      animals.Add(new Animal("Gray Wolf", "Carnivora"));
      animals.Add(new Animal("Capybara", "Rodent"));
      string output = String.Concat(animals.Where( animal => 
                      (animal.Order == "Rodent")));
      Console.WriteLine(output);  
   }
}
// The example displays the following output:
//      SquirrelCapybara
Imports System.Collections.Generic

Public Class Animal
   Public Kind As String
   Public Order As String
   
   Public Sub New(kind As String, order As String)
      Me.Kind = kind
      Me.Order = order
   End Sub
   
   Public Overrides Function ToString() As String
      Return Me.Kind
   End Function
End Class

Module Example
   Public Sub Main()
      Dim animals As New List(Of Animal)
      animals.Add(New Animal("Squirrel", "Rodent"))
      animals.Add(New Animal("Gray Wolf", "Carnivora"))
      animals.Add(New Animal("Capybara", "Rodent")) 
      Dim output As String = String.Concat(animals.Where(Function(animal) _
                                           animal.Order = "Rodent"))
      Console.WriteLine(output)                                           
   End Sub
End Module
' The example displays the following output:
'      SquirrelCapybara

注釈

メソッドは、内の各valuesオブジェクトを連結します。区切り記号は追加されません。The method concatenates each object in values; it does not add any delimiters.

Null 引数の代わりに文字列を使用します。EmptyAn Empty string is used in place of any null argument.

Concat<T>(IEnumerable<T>)は、最初に要素を文字列に変換せずにIEnumerable<T> 、コレクション内の各要素を連結できる便利なメソッドです。Concat<T>(IEnumerable<T>) is a convenience method that lets you concatenate each element in an IEnumerable<T> collection without first converting the elements to strings. この例に示すように、統合言語クエリ (LINQ) クエリ式では特に便利です。It is particularly useful with Language-Integrated Query (LINQ) query expressions, as the example illustrates. IEnumerable<T>コレクション内の各オブジェクトの文字列形式は、そのオブジェクトのToStringメソッドを呼び出すことによって派生されます。The string representation of each object in the IEnumerable<T> collection is derived by calling that object's ToString method.

適用対象