本文整理汇总了C#中System.Runtime.InteropServices.StringBuffer.SetLengthToFirstNull方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuffer.SetLengthToFirstNull方法的具体用法?C# StringBuffer.SetLengthToFirstNull怎么用?C# StringBuffer.SetLengthToFirstNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Runtime.InteropServices.StringBuffer
的用法示例。
在下文中一共展示了StringBuffer.SetLengthToFirstNull方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetLengthToFirstNullEmptyBuffer
public unsafe void SetLengthToFirstNullEmptyBuffer()
{
using (var buffer = new StringBuffer())
{
buffer.SetLengthToFirstNull();
Assert.Equal((ulong)0, buffer.Length);
}
}
示例2: SetLengthToFirstNullTests
public unsafe void SetLengthToFirstNullTests(string content, ulong startLength, ulong endLength)
{
using (var buffer = new StringBuffer(content))
{
// With existing content
Assert.Equal(startLength, buffer.Length);
buffer.SetLengthToFirstNull();
Assert.Equal(endLength, buffer.Length);
// Clear the buffer & manually copy in
buffer.Length = 0;
fixed (char* contentPointer = content)
{
Buffer.MemoryCopy(contentPointer, buffer.CharPointer, (long)buffer.CharCapacity * 2, content.Length * sizeof(char));
}
Assert.Equal((ulong)0, buffer.Length);
buffer.SetLengthToFirstNull();
Assert.Equal(endLength, buffer.Length);
}
}
示例3: SetLengthToFirstNullNoNull
public unsafe void SetLengthToFirstNullNoNull()
{
using (var buffer = new StringBuffer("A"))
{
// Wipe out the last null
buffer.CharPointer[buffer.Length] = 'B';
buffer.SetLengthToFirstNull();
Assert.Equal((ulong)1, buffer.Length);
}
}