ArgumentOutOfRangeException — argument outside the allowed range
System.ArgumentOutOfRangeException signals that an argument value is outside the set accepted by a method. The exception can identify the parameter name and the rejected value.
CKTIS / C#
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
System.ArgumentOutOfRangeException signals that an argument value is outside the set accepted by a method. The exception can identify the parameter name and the rejected value.
Combine Array.Clone with Array.Sort to obtain a sorted array copy without changing the original element order. Learn how a shallow copy differs from sharing the same array.
Array.Empty<T>() returns a non-null array of type T[] with length zero. Use it to represent no elements without creating a new empty array on every call.
System.Array.IndexOf finds the first occurrence of a value in an array or a range and returns its index.
Array.Length returns an array's element count as int. For a multidimensional array it covers every dimension, and for an empty array it is 0.
AttributeUsageAttribute specifies where a custom attribute may be applied, whether it may be repeated, and whether it is inherited. AttributeTargets.Property restricts its use to properties.
Boolean.Parse converts text representing True or False to bool. It ignores letter case and leading or trailing whitespace and NUL characters. Invalid input throws an exception rather than returning false.
Console.Out exposes a TextWriter representing the application's standard output. It supports direct text output and follows redirection configured through Console.SetOut.
Console.Write writes text to standard output without automatically ending the line. It lets you build output across several calls; Console.WriteLine additionally appends a line terminator.
Convert.ToInt32(Boolean) converts false to 0 and true to 1. This static overload on System.Convert returns int and lets you explicitly represent a Boolean value as a number.
CustomAttributeExtensions.GetCustomAttribute<T> retrieves a single attribute of type T through reflection. Learn its supported targets, null handling, and why multiple matches cause an exception.
System.DivideByZeroException signals division by zero for integers and decimal. Learn how to handle it and how this differs from float and double, which can return infinity or NaN instead.
Double.Parse converts text to double. Culture determines separators, while NumberStyles controls the permitted syntax.
Double.ToString(string, IFormatProvider) converts a double value to text while letting you choose the numeric format and cultural rules separately. If the provider's GetFormat method returns null when asked for NumberFormatInfo, formatting falls back to the current culture.
Use Encoding.ASCII to encode a ReadOnlySpan<char> into a Span<byte> buffer. GetByteCount calculates the required size, while GetBytes writes the bytes and returns their count. Default replacement of non-ASCII text can lose data.
Enumerable.Aggregate: practical reference: Immediately enumerates the source and folds its elements into one value with an accumulator. The seeded overload starts from the explicit seed; the unseeded overload uses the first element.
Enumerable.All: practical reference: Immediately tests the predicate and stops at the first element that returns false. It returns true only when every element read satisfies the condition.
Enumerable.Any: practical reference: Without a predicate it tests whether an element exists; with a predicate it stops at the first true match. It does not count the whole sequence when it can answer earlier.
Enumerable.AsEnumerable: practical reference: Returns the same reference viewed through IEnumerable<T>; it neither copies, buffers, nor enumerates elements. It can also force selection of LINQ-to-Objects operators.
Enumerable.Average: practical reference: Immediately enumerates numeric values and returns the mean in the overload-specific result type. Nullable overloads ignore null values.
Enumerable.Chunk: practical reference: Deferred enumeration groups consecutive elements into new arrays whose length is at most size. The final array can be shorter.
Enumerable.Concat: practical reference: The deferred result yields every element of the first source and then every element of the second, retaining duplicates.
Enumerable.Contains: practical reference: Immediately enumerates to the first element equal to the sought value under the supplied IEqualityComparer<T> or EqualityComparer<T>.Default.
Enumerable.Count: practical reference: Returns the number of all elements or of elements satisfying a predicate. It may read a collection Count without enumeration, but enumerates a general IEnumerable<T>.