public virtual unsafe ICharSequence GetCharSequence(int index, int length, Encoding encoding) { this.CheckIndex0(index, length); if (length == 0) { return(StringCharSequence.Empty); } if (this.HasMemoryAddress) { IntPtr ptr = this.AddressOfPinnedMemory(); if (ptr != IntPtr.Zero) { return(new StringCharSequence(UnsafeByteBufferUtil.GetString((byte *)(ptr + index), length, encoding))); } else { fixed(byte *p = &this.GetPinnableMemoryAddress()) return(new StringCharSequence(UnsafeByteBufferUtil.GetString(p + index, length, encoding))); } } if (this.HasArray) { return(new StringCharSequence(encoding.GetString(this.Array, this.ArrayOffset + index, length))); } return(new StringCharSequence(this.ToString(index, length, encoding))); }