예제 #1
0
파일: Span.cs 프로젝트: anydream/coreclr
        public Span(T[] array)
        {
            if (array == null)
            {
                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
            }
            if (default(T) == null && array.GetInternalTypeID() != RuntimeHelpers.GetInternalTypeID <T[]>())
            {
                ThrowHelper.ThrowArrayTypeMismatchException();
            }

            _pointer = new ByReference <T>(ref Unsafe.As <byte, T>(ref array.GetRawSzArrayData()));
            _length  = array.Length;
        }
예제 #2
0
파일: Span.cs 프로젝트: anydream/coreclr
        public Span(T[] array, int start, int length)
        {
            if (array == null)
            {
                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array);
            }
            if (default(T) == null && array.GetInternalTypeID() != RuntimeHelpers.GetInternalTypeID <T[]>())
            {
                ThrowHelper.ThrowArrayTypeMismatchException();
            }
            if ((uint)start > (uint)array.Length || (uint)length > (uint)(array.Length - start))
            {
                ThrowHelper.ThrowArgumentOutOfRangeException();
            }

            _pointer = new ByReference <T>(ref Unsafe.Add(ref Unsafe.As <byte, T>(ref array.GetRawSzArrayData()), start));
            _length  = length;
        }