本文整理汇总了C#中Span.Validate方法的典型用法代码示例。如果您正苦于以下问题:C# Span.Validate方法的具体用法?C# Span.Validate怎么用?C# Span.Validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Span
的用法示例。
在下文中一共展示了Span.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 };
Span<int> span = new Span<int>(a, 3);
span.Validate<int>();
}
示例2: CtorPointerNull
public static void CtorPointerNull()
{
unsafe
{
Span<int> span = new Span<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)
{
Span<int> span = new Span<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>();
Span<int> span;
span = new Span<int>(empty);
span.Validate<int>();
span = new Span<int>(empty, 0);
span.Validate<int>();
span = new Span<int>(empty, 0, empty.Length);
span.Validate<int>();
}
示例5: CtorArray2
public static void CtorArray2()
{
long[] a = { 91, -92, 93, 94, -95 };
Span<long> span;
span = new Span<long>(a);
span.Validate<long>(91, -92, 93, 94, -95);
span = new Span<long>(a, 0);
span.Validate<long>(91, -92, 93, 94, -95);
span = new Span<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 };
Span<int> span;
span = new Span<int>(a);
span.Validate<int>(91, 92, -93, 94);
span = new Span<int>(a, 0);
span.Validate<int>(91, 92, -93, 94);
span = new Span<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 };
Span<object> span;
span = new Span<object>(a);
span.Validate<object>(o1, o2);
span = new Span<object>(a, 0);
span.Validate<object>(o1, o2);
span = new Span<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;
Span<int> span;
span = new Span<int>(aAsIntArray);
span.Validate<int>(42, -1);
span = new Span<int>(aAsIntArray, 0);
span.Validate<int>(42, -1);
span = new Span<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 };
Span<long> span = new Span<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 };
Span<int> span = new Span<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 };
Span<long> span = new Span<long>(a, 4, 5);
span.Validate<long>(94, 95, 96, 97, 98);
}