本文整理汇总了C#中ReadOnlySpan.Validate方法的典型用法代码示例。如果您正苦于以下问题:C# ReadOnlySpan.Validate方法的具体用法?C# ReadOnlySpan.Validate怎么用?C# ReadOnlySpan.Validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReadOnlySpan
的用法示例。
在下文中一共展示了ReadOnlySpan.Validate方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CtorArrayIntStartEqualsLength
public static void CtorArrayIntStartEqualsLength()
{
// Valid for start to equal the array length. This returns an empty span that starts "just past the array."
int[] a = { 91, 92, 93 };
ReadOnlySpan<int> span = new ReadOnlySpan<int>(a, 3);
span.Validate<int>();
}
示例2: CtorPointerNull
public static void CtorPointerNull()
{
unsafe
{
ReadOnlySpan<int> span = new ReadOnlySpan<int>((void*)null, 0);
span.Validate<int>();
Assert.True(Unsafe.AreSame<int>(ref Unsafe.AsRef<int>((void*)null), ref span.DangerousGetPinnableReference()));
}
}
示例3: CtorPointerInt
public static void CtorPointerInt()
{
unsafe
{
int[] a = { 90, 91, 92 };
fixed (int *pa = a)
{
ReadOnlySpan<int> span = new ReadOnlySpan<int>(pa, 3);
span.Validate<int>(90, 91, 92);
Assert.True(Unsafe.AreSame<int>(ref Unsafe.AsRef<int>(pa), ref span.DangerousGetPinnableReference()));
}
}
}
示例4: CtorArrayZeroLength
public static void CtorArrayZeroLength()
{
int[] empty = Array.Empty<int>();
ReadOnlySpan<int> span;
span = new ReadOnlySpan<int>(empty);
span.Validate<int>();
span = new ReadOnlySpan<int>(empty, 0);
span.Validate<int>();
span = new ReadOnlySpan<int>(empty, 0, empty.Length);
span.Validate<int>();
}
示例5: CtorArray2
public static void CtorArray2()
{
long[] a = { 91, -92, 93, 94, -95 };
ReadOnlySpan<long> span;
span = new ReadOnlySpan<long>(a);
span.Validate<long>(91, -92, 93, 94, -95);
span = new ReadOnlySpan<long>(a, 0);
span.Validate<long>(91, -92, 93, 94, -95);
span = new ReadOnlySpan<long>(a, 0, a.Length);
span.Validate<long>(91, -92, 93, 94, -95);
}
示例6: CtorArray1
public static void CtorArray1()
{
int[] a = { 91, 92, -93, 94 };
ReadOnlySpan<int> span;
span = new ReadOnlySpan<int>(a);
span.Validate<int>(91, 92, -93, 94);
span = new ReadOnlySpan<int>(a, 0);
span.Validate<int>(91, 92, -93, 94);
span = new ReadOnlySpan<int>(a, 0, a.Length);
span.Validate<int>(91, 92, -93, 94);
}
示例7: CtorArray3
public static void CtorArray3()
{
object o1 = new object();
object o2 = new object();
object[] a = { o1, o2 };
ReadOnlySpan<object> span;
span = new ReadOnlySpan<object>(a);
span.Validate<object>(o1, o2);
span = new ReadOnlySpan<object>(a, 0);
span.Validate<object>(o1, o2);
span = new ReadOnlySpan<object>(a, 0, a.Length);
span.Validate<object>(o1, o2);
}
示例8: CtorArrayWrongValueType
public static void CtorArrayWrongValueType()
{
// Can pass variant array, if array type is a valuetype.
uint[] a = { 42u, 0xffffffffu };
int[] aAsIntArray = (int[])(object)a;
ReadOnlySpan<int> span;
span = new ReadOnlySpan<int>(aAsIntArray);
span.Validate<int>(42, -1);
span = new ReadOnlySpan<int>(aAsIntArray, 0);
span.Validate<int>(42, -1);
span = new ReadOnlySpan<int>(aAsIntArray, 0, aAsIntArray.Length);
span.Validate<int>(42, -1);
}
示例9: CtorArrayInt2
public static void CtorArrayInt2()
{
long[] a = { 90, 91, 92, 93, 94, 95, 96, 97, 98 };
ReadOnlySpan<long> span = new ReadOnlySpan<long>(a, 3);
span.Validate<long>(93, 94, 95, 96, 97, 98);
}
示例10: CtorArrayInt1
public static void CtorArrayInt1()
{
int[] a = { 90, 91, 92, 93, 94, 95, 96, 97, 98 };
ReadOnlySpan<int> span = new ReadOnlySpan<int>(a, 3);
span.Validate<int>(93, 94, 95, 96, 97, 98);
}
示例11: CtorArrayIntIntRangeExtendsToEndOfArray
public static void CtorArrayIntIntRangeExtendsToEndOfArray()
{
long[] a = { 90, 91, 92, 93, 94, 95, 96, 97, 98 };
ReadOnlySpan<long> span = new ReadOnlySpan<long>(a, 4, 5);
span.Validate<long>(94, 95, 96, 97, 98);
}