本文由机器翻译。若要查看英语原文,请勾选“英语”复选框。 也可将鼠标指针移到文本上,在弹出窗口中显示英语原文。
翻译
英语

String.Concat 方法 (String, String)

 

连接 String 的两个指定实例。

命名空间:   System
程序集:  mscorlib(位于 mscorlib.dll)

public static string Concat(
	string str0,
	string str1
)

参数

str0
Type: System.String

要串联的第一个字符串。

str1
Type: System.String

要串联的第二个字符串。

返回值

Type: System.String

str0str1 的串联。

The method concatenates str0 and str1; it does not add any delimiters.

System_CAPS_note说明

You can also use your language's string concatenation operator, such as + in C#, or & and + in Visual Basic)

, to concatenate strings.

An F:System.String.Empty string is used in place of any null argument.

The following example concatenates a person's first, middle, and last name.

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'!

通用 Windows 平台
自 8 起可用
.NET Framework
自 1.1 起可用
可移植类库
可移植 .NET 平台 中受支持
Silverlight
自 2.0 起可用
Windows Phone Silverlight
自 7.0 起可用
Windows Phone
自 8.1 起可用
返回页首
显示: