System.SpanTests.ReadOnlySpanTests.CtorArrayWrongArrayType C# (CSharp) Méthode

CtorArrayWrongArrayType() private méthode

private CtorArrayWrongArrayType ( ) : void
Résultat void
        public static void CtorArrayWrongArrayType()
        {
            // Cannot pass variant array, if array type is not a valuetype.
            string[] a = { "Hello" };
            Assert.Throws<ArrayTypeMismatchException>(() => new ReadOnlySpan<object>(a).DontBox());
            Assert.Throws<ArrayTypeMismatchException>(() => new ReadOnlySpan<object>(a, 0).DontBox());
            Assert.Throws<ArrayTypeMismatchException>(() => new ReadOnlySpan<object>(a, 0, a.Length).DontBox());
        }