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
/// <param name="length">The length of the subsequence.</param>
89
-
/// <param name="default">The value to return if <paramref name="source"/> is empty or shorter than <paramref name="length"/>.</param>
90
-
/// <returns>A random subsequence of length <paramref name="length"/>, or <paramref name="default"/> if <paramref name="source"/> is empty or shorted than that length.</returns>
93
+
/// <param name="defaultValue">The value to return if <paramref name="source"/> is empty or shorter than <paramref name="length"/>.</param>
94
+
/// <returns>A random subsequence of length <paramref name="length"/>, or <paramref name="defaultValue"/> if <paramref name="source"/> is empty or shorted than that length.</returns>
91
95
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="length"/> is negative.</exception>
92
-
/// <exception cref="ArgumentException">If the length of <paramref name="default"/> did not match <paramref name="length"/>.</exception>
thrownewArgumentException("The length must match.",nameof(@default));
105
+
thrownewArgumentException("The length must match.",nameof(defaultValue));
102
106
}
103
107
104
108
if(source.Length<length)
105
109
{
106
-
return@default??newT[length];
110
+
returndefaultValue??newT[length];
107
111
}
108
112
109
113
intstartIndex=random.Next(source.Length-length);
@@ -117,28 +121,28 @@ public static T[] RandomSubsequenceOrDefault<T>(this ReadOnlySpan<T> source, int
117
121
/// <typeparam name="T">The type of the target array.</typeparam>
118
122
/// <param name="array">The target array.</param>
119
123
/// <param name="length">The length of the subsequence.</param>
120
-
/// <param name="default">The value to return if <paramref name="array"/> is empty or shorter than <paramref name="length"/>.</param>
121
-
/// <returns>A random subsequence of length <paramref name="length"/>, or <paramref name="default"/> if the array is empty or shorted than that length.</returns>
124
+
/// <param name="defaultValue">The value to return if <paramref name="array"/> is empty or shorter than <paramref name="length"/>.</param>
125
+
/// <returns>A random subsequence of length <paramref name="length"/>, or <paramref name="defaultValue"/> if the array is empty or shorted than that length.</returns>
122
126
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="length"/> is negative.</exception>
123
-
/// <exception cref="ArgumentException">If the length of <paramref name="default"/> did not match <paramref name="length"/>.</exception>
/// <param name="length">The length of the string.</param>
135
-
/// <param name="default">The value to return if <paramref name="string"/> is empty or shorter than <paramref name="length"/>.</param>
136
-
/// <returns>A random subsequence of length <paramref name="length"/>, or <paramref name="default"/> if <paramref name="string"/> is empty or shorted than that length.</returns>
139
+
/// <param name="defaultValue">The value to return if <paramref name="source"/> is empty or shorter than <paramref name="length"/>.</param>
140
+
/// <returns>A random subsequence of length <paramref name="length"/>, or <paramref name="defaultValue"/> if <paramref name="source"/> is empty or shorted than that length.</returns>
137
141
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="length"/> is negative.</exception>
138
-
/// <exception cref="ArgumentException">If the length of <paramref name="default"/> did not match <paramref name="length"/>.</exception>
0 commit comments