public MyStringClass Insert(int index, MyStringClass str) { char[] temp = new char[this.Length + str.Length]; if (index != 0) { for (int i = 0; i < index; i++) { temp[i] = this.chars[i]; } int tempCount = 0; for (int i = index; i < index + str.Length; i++) { temp[i] = str.chars[tempCount++]; } if (temp.Length != index + str.Length) { tempCount = index; for (int i = index + str.Length; i < temp.Length; i++) { temp[i] = this.chars[tempCount++]; } } } else { for (int i = index; i < index + str.Length; i++) { temp[i] = str.chars[i]; } if (temp.Length != index + str.Length) { int tempCount = 0; for (int i = index + str.Length; i < temp.Length; i++) { temp[i] = this.chars[tempCount++]; } } } MyStringClass tempObject = new MyStringClass(temp); return tempObject; }
public int CompareTo(MyStringClass strB) { if (this > strB) { return 1; } if (this < strB) { return -1; } return 0; }
public static MyStringClass Concat(char[] arr) { MyStringClass temp = new MyStringClass(arr); return temp; }
public static MyStringClass Concat(MyStringClass strA, MyStringClass strB) { MyStringClass str = new MyStringClass(strA + strB); return str; }