当前位置: 首页>>代码示例>>C#>>正文


C# ReadOnlySpan.Validate方法代码示例

本文整理汇总了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>();
 }
开发者ID:dotnet,项目名称:corefx,代码行数:7,代码来源:CtorArrayInt.cs

示例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()));
     }
 }
开发者ID:dotnet,项目名称:corefx,代码行数:9,代码来源:CtorPointerInt.cs

示例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()));
         }
     }
 }
开发者ID:dotnet,项目名称:corefx,代码行数:13,代码来源:CtorPointerInt.cs

示例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>();
        }
开发者ID:kouvel,项目名称:corefx,代码行数:14,代码来源:CtorArray.cs

示例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);
        }
开发者ID:kouvel,项目名称:corefx,代码行数:14,代码来源:CtorArray.cs

示例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);
        }
开发者ID:kouvel,项目名称:corefx,代码行数:14,代码来源:CtorArray.cs

示例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);
        }
开发者ID:kouvel,项目名称:corefx,代码行数:16,代码来源:CtorArray.cs

示例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);
        }
开发者ID:kouvel,项目名称:corefx,代码行数:17,代码来源:CtorArray.cs

示例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);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:6,代码来源:CtorArrayInt.cs

示例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);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:6,代码来源:CtorArrayInt.cs

示例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);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:6,代码来源:CtorArrayIntInt.cs


注:本文中的ReadOnlySpan.Validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。