一、概述
连接 String 的一个或多个实例,或 Object 的一个或多个实例的值的 String 表示形式。
二. 表现形式
1.
public static string Concat(
object arg0
);
参数
-
arg0
- Object 或空引用(Visual Basic 中为 Nothing)。
返回值
arg0 的值的 String 表示形式。
备注
使用 Empty 字符串替代任何空参数
示例
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
*/
This example produces the following output:
Concatenate 1, 2, and 3 objects:
1) -123
2) -123-123
3) -123-123-123
4) -123-123-123-123-123
5) -123-456-789
*/
博客主要介绍了连接 String 或 Object 实例值的 String 表示形式的方法。详细说明了该方法的参数、返回值和备注,使用空字符串替代空参数。还给出了具体示例,展示了连接不同数量对象及对象数组时的输出结果。
1778





