public unsafe void AppendString(string stringToAppend) { if (!string.IsNullOrEmpty(stringToAppend)) { if ((this.m_totalSize - this.m_length) < stringToAppend.Length) { throw new IndexOutOfRangeException(); } fixed(char *str = ((char *)stringToAppend)) { char *chPtr = str; Buffer.memcpyimpl((byte *)chPtr, (byte *)(this.m_buffer + this.m_length), stringToAppend.Length * 2); } this.m_length += stringToAppend.Length; } }
public void AppendString(string stringToAppend) { if (String.IsNullOrEmpty(stringToAppend)) { return; } if ((m_totalSize - m_length) < stringToAppend.Length) { throw new IndexOutOfRangeException(); } fixed(char *pointerToString = stringToAppend) { Buffer.memcpyimpl((byte *)pointerToString, (byte *)(m_buffer + m_length), stringToAppend.Length * sizeof(char)); } m_length += stringToAppend.Length; BCLDebug.Assert(m_length <= m_totalSize, "Buffer has been overflowed!"); }