zoukankan      html  css  js  c++  java
  • 复制字符串

    要复制字符串可以使用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);

  • 相关阅读:
    ACM-ICPC ShangHai 2014
    DEBUG感想
    WireShark 使用日记
    C++ 备忘录
    BZOJ 1022 [SHOI2008]小约翰的游戏John
    高斯消元
    BZOJ3236 [Ahoi2013]作业
    BZOJ P3293&&P1045
    ZKW费用流的理解
    BZOJ 几道水题 2014-4-22
  • 原文地址:https://www.cnblogs.com/lichen396116416/p/1920461.html
Copyright © 2011-2022 走看看