You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if(startIndexis not (0 or -1))thrownewArgumentOutOfRangeException(paramName:nameof(startIndex),actualValue:startIndex,message:"Value must be zero or -1 for empty arrays.");
43
+
if(count!=0)thrownewArgumentOutOfRangeException(paramName:nameof(count),actualValue:count,message:"Value must be zero for empty arrays.");
44
+
}
45
+
else
46
+
{
47
+
if(count<0)thrownewArgumentOutOfRangeException(paramName:nameof(count),actualValue:count,message:"Value must be non-negative.");
48
+
if(startIndex<0)thrownewArgumentOutOfRangeException(paramName:nameof(startIndex),actualValue:startIndex,message:"Value must be non-negative.");
49
+
50
+
if(startIndex>=array.Length)thrownewArgumentOutOfRangeException(paramName:nameof(startIndex),actualValue:startIndex,message:"Value exceeds the length of the provided array.");
51
+
if(startIndex+count>array.Length)thrownewArgumentOutOfRangeException(paramName:nameof(count),actualValue:count,message:"Value (plus "+nameof(startIndex)+") exceeds the length of the provided array.");
52
+
}
53
+
}
54
+
55
+
publicTthis[intindex]
56
+
{
57
+
get
58
+
{
59
+
if(index<0||index>=this.count)
60
+
{
61
+
thrownewArgumentOutOfRangeException(paramName:nameof(index),actualValue:index,message:"Value must be between 0 and "+nameof(this.Length)+" (exclusive).");
62
+
}
63
+
else
64
+
{
65
+
intsourceIndex=this.startIndex+index;
66
+
returnthis.array[sourceIndex];
67
+
}
68
+
}
69
+
}
70
+
71
+
publicintLength=>this.count;
72
+
publicintCount=>this.count;// Specifying both Length and Count for source-level compatibility with both IReadOnlyList<T>.Count and Array<T>.Length (and of course, ReadOnlySpan<T>.Length)
/// <remarks>This method exists because using Linq's extensions over <see cref="IEnumerable{T}"/> or <see cref="IReadOnlyList{T}"/> are a lot slower than doing it directly.</remarks>
0 commit comments