String.Concat メソッド (String )
指定した String 配列の要素を連結します。
Overloads Public Shared Function Concat( _
ByVal ParamArray values() As String _) As String
[C#]
public static string Concat( params string[] values);
[C++]
public: static String* Concat(String* values __gc[]);
[JScript]
public static function Concat(
values : String[]) : String;
パラメータ
- values
String インスタンスの配列。
戻り値
連結された values の要素。
例外
例外の種類 | 条件 |
---|---|
ArgumentNullException | values が null 参照 (Visual Basic では Nothing) です。 |
解説
Empty 文字列は、配列内の任意の null オブジェクトの代わりに使用されます。
使用例
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
[C#]
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));
}
}
[C++]
#using <mscorlib.dll>
using namespace System;
int main()
{
// make an array of strings. Note that we have included spaces
String* s[] = { S"hello ", S"and ", S"welcome ", S"to ", S"this ", S"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));
}
[JScript]
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();
必要条件
プラットフォーム: 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 オーバーロードの一覧 | Join