要复制字符串可以使用String类中的Copy和CopyTo 这个两个方法
创建一个由str的参数,指定的字符串的副本,即生成一个当前的新实例;
Public static string Copy(string str)
将指定数码的字符从源实例中的指定位置复制到目标位置,
public void CopyTo(int Sourveindex,char[] destination,int destinationindex,int count)
其中sourcelndex 是参数
destination 调用此方法的字符串中的位置
destination 目标Unicode字符的数组
count 是destinationindex中的数组元素的索引
演示代码
string sourcestr = "这是源字符串";
//使用Copy方法产生一个新的字符串
string destinationstr = String.Copy(sourcestr);
Console.WriteLine("Copy 方法的结果是:{0}",destinationstr);
//-------------------------------------------------
char[] destination = {'T','h','e',' ','i','n','i','t','i','a','i',' ','a','r','r','y'};
Console.WriteLine(destinationstr);
sourcestr.CopyTo(0, destination, 4, sourcestr.Length - 1);
Console.WriteLine("===================");
Console.WriteLine(destination);