String.Concat メソッド (String, String, String)
指定した 3 つの String インスタンスを連結します。
Overloads Public Shared Function Concat( _
ByVal str0 As String, _ ByVal str1 As String, _ ByVal str2 As String _) As String
[C#]
public static string Concat(stringstr0,stringstr1,stringstr2);
[C++]
public: static String* Concat(String* str0,String* str1,String* str2);
[JScript]
public static function Concat(
str0 : String,str1 : String,str2 : String) : String;
パラメータ
戻り値
str0 、 str1 、および str2 の連結結果。
解説
Empty 文字列は、任意の null 引数の代わりに使用されます。
使用例
この 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
[C#]
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
*/
}
}
[C++]
#using <mscorlib.dll>
using namespace System;
using namespace System::Globalization;
void main ()
{
DateTime dt = DateTime::Now;
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
*/
}
[JScript]
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
*/
必要条件
プラットフォーム: 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