コード例 #1
0
 public static MyString Concat(MyString arg0, MyString arg1)
 {
     char[] resultCharArray = new char[arg0.Length + arg1.Length];
     Array.Copy(arg0.ToCharArray(), 0, resultCharArray, 0, arg0.Length);
     Array.Copy(arg1.ToCharArray(), 0, resultCharArray, arg0.Length, arg1.Length);
     return(new MyString(resultCharArray));
 }
コード例 #2
0
        public MyString Insert(MyString myStr, int pos)
        {
            if (pos < 0 || pos > this.Length)
            {
                throw new ArgumentOutOfRangeException("Target position must be positive and less than length of MyString");
            }

            char[] res = new char[this.Length + myStr.Length];
            Array.Copy(this.ToCharArray(), 0, res, 0, pos);
            Array.Copy(myStr.ToCharArray(), 0, res, pos, myStr.Length);
            Array.Copy(this.ToCharArray(), pos, res, pos + myStr.Length, this.Length - pos);

            return(new MyString(res));
        }