public string Substring(int startIndex) { if (startIndex == 0) { return(this as object as string); } if (startIndex < 0 || startIndex > this.length) { throw new System.ArgumentOutOfRangeException("startIndex"); } int newlen = this.length - startIndex; InternalSystem.String result = InternalAllocateStr(newlen); unsafe { char *ptrres = result._GetBuffer(); char *ptr = this._GetBuffer(); ptr = ptr + startIndex; for (int i = 0; i < newlen; i++) { *ptrres = *ptr; ptrres++; ptr++; } } return(result as object as string); }
public static string CreateStringImpl(char[] val) { if (val == null) { return(string.Empty); } if (val.Length == 0) { return(string.Empty); } InternalSystem.String result = InternalAllocateStr(val.Length); //"safe" implementation //for (int i = 0; i < val.Length; i++) // result[i] = val[i]; unsafe { char *ptrres = result._GetBuffer(); for (int i = 0; i < val.Length; i++) { *ptrres = val[i]; ptrres++; } } return(result as object as string); }
public static string Concat(InternalSystem.String[] strings) { int length = 0; foreach (String s in strings) { length = length + s.Length; } InternalSystem.String result = InternalAllocateStr(length); unsafe { char *ptrres = result._GetBuffer(); foreach (String s in strings) { char *ptr = s._GetBuffer(); for (int i = 0; i < s.length; i++) { *ptrres = *ptr; ptrres++; ptr++; } } } return(result as object as string); }
public static string Concat(InternalSystem.String a, InternalSystem.String b, InternalSystem.String c) { InternalSystem.String result = InternalAllocateStr(a.length + b.length + c.length); unsafe { char *ptrres = result._GetBuffer(); char *ptr = a._GetBuffer(); for (int i = 0; i < a.length; i++) { *ptrres = *ptr; ptrres++; ptr++; } ptr = b._GetBuffer(); for (int i = 0; i < b.length; i++) { *ptrres = *ptr; ptrres++; ptr++; } ptr = c._GetBuffer(); for (int i = 0; i < c.length; i++) { *ptrres = *ptr; ptrres++; ptr++; } } return(result as object as string); }
public static string CreateStringImpl(uint value, bool signed, bool hex) { int offset = 0; uint uvalue = (uint)value; ushort divisor = hex ? (ushort)16 : (ushort)10; int length = 0; int count = 0; uint temp; bool negative = false; if (value < 0 && !hex && signed) { count++; uvalue = (uint)-value; negative = true; } temp = uvalue; do { temp /= divisor; count++; }while (temp != 0); length = count; InternalSystem.String result = InternalAllocateStr(length); unsafe { fixed(char *p = &result.firstChar) { if (negative) { p[offset++] = '-'; count--; } for (int i = 0; i < count; i++) { uint remainder = uvalue % divisor; if (remainder < 10) { p[offset + count - 1 - i] = (char)('0' + remainder); } else { p[offset + count - 1 - i] = (char)('A' + remainder - 10); } uvalue /= divisor; } } } return(result as object as string); }
private static unsafe bool CompareChars(InternalSystem.String a, InternalSystem.String b) { fixed(char *pa = &a.firstChar) { fixed(char *pb = &b.firstChar) { for (int i = 0; i < a.Length; ++i) { if (pa[i] != pb[i]) { return(false); } } } } return(true); }
public string Substring(int startIndex, int length) { if (length < 0) { throw new System.ArgumentOutOfRangeException("length", "< 0"); } if (startIndex < 0) { throw new System.ArgumentOutOfRangeException("startIndex", "< 0"); } if (startIndex > this.length - length) { throw new System.ArgumentOutOfRangeException("startIndex + length > this.length"); } if (length == 0) { return(String.Empty); } InternalSystem.String result = InternalAllocateStr(length); unsafe { char *ptrres = result._GetBuffer(); char *ptr = this._GetBuffer(); ptr = ptr + startIndex; for (int i = 0; i < length; i++) { *ptrres = *ptr; ptrres++; ptr++; } } return(result as object as string); }
public static string CreateStringImpl(char[] val, int startIndex, int length) { if (val == null) { throw new System.ArgumentNullException("val"); } if (startIndex < 0) { throw new System.ArgumentOutOfRangeException("startIndex"); } if (length < 0) { throw new System.ArgumentOutOfRangeException("length"); } if (startIndex > val.Length - length) { throw new System.ArgumentOutOfRangeException("Out of range"); } if (length == 0) { return(string.Empty); } InternalSystem.String result = InternalAllocateStr(length); unsafe { char *ptrres = result._GetBuffer(); for (int i = startIndex; i < length; i++) { *ptrres = val[i]; ptrres++; } } return(result as object as string); }
internal CharEnumerator (InternalSystem.String _string) { internalString = _string; index = -1; }
internal CharEnumerator(InternalSystem.String _string) { internalString = _string; index = -1; }