Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C#

Knowledge base — C#

Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.

Entries: 443

C#

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.

Basic · .NET 10; repository net10.0 and LangVersion=preview; feature versions require per-entry verification
C#

Array.Clone and Array.Sort: sorting an array copy

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.

Basic · .NET 10; repository net10.0 and LangVersion=preview; feature versions require per-entry verification
C#

Array.Empty<T> — an empty array of a specified type

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.

Basic · .NET 10; repository net10.0 and LangVersion=preview; feature versions require per-entry verification
C#

Array.IndexOf — index of the first occurrence

System.Array.IndexOf finds the first occurrence of a value in an array or a range and returns its index.

Basic · .NET 10; repository net10.0 and LangVersion=preview; feature versions require per-entry verification
C#

Array.Length — array element count

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.

Basic · .NET 10; repository net10.0 and LangVersion=preview; feature versions require per-entry verification
C#

AttributeUsageAttribute — rules for custom attributes

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.

Intermediate · .NET 10; repository net10.0 and LangVersion=preview; feature versions require per-entry verification
C#

Boolean.Parse — converting text to a Boolean value

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.

Basic · .NET 10; repository net10.0 and LangVersion=preview; feature versions require per-entry verification
C#

Console.Out — the standard output writer

Console.Out exposes a TextWriter representing the application's standard output. It supports direct text output and follows redirection configured through Console.SetOut.

Basic · .NET 10; repository net10.0 and LangVersion=preview; feature versions require per-entry verification
C#

Console.Write — write without adding a newline

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.

Basic · .NET 10; repository net10.0 and LangVersion=preview; feature versions require per-entry verification
C#

Convert.ToInt32(Boolean) — convert bool to 0 or 1

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.

Basic · .NET 10; repository net10.0 and LangVersion=preview; feature versions require per-entry verification
C#

GetCustomAttribute<T> — reading a single attribute

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.

Intermediate · .NET 10; repository net10.0 and LangVersion=preview; feature versions require per-entry verification
C#

DivideByZeroException — division by zero

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.

Basic · .NET 10; repository net10.0 and LangVersion=preview; feature versions require per-entry verification
C#

Double.Parse — converting text to double

Double.Parse converts text to double. Culture determines separators, while NumberStyles controls the permitted syntax.

Basic · .NET 10; repository net10.0 and LangVersion=preview; feature versions require per-entry verification
C#

Double.ToString — formatting a number with an explicit provider

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.

Basic · .NET 10; repository net10.0 and LangVersion=preview; feature versions require per-entry verification
C#

Encoding ASCII into a Span<byte> buffer

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.

Intermediate · .NET 10; repository net10.0 and LangVersion=preview; feature versions require per-entry verification
C#

Enumerable.Aggregate: practical reference

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.

Basic · .NET LINQ; verified on .NET 10.0.14
C#

Enumerable.All: practical reference

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.

Basic · .NET LINQ; verified on .NET 10.0.14
C#

Enumerable.Any: practical reference

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.

Basic · .NET LINQ; verified on .NET 10.0.14
C#

Enumerable.AsEnumerable: practical reference

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.

Basic · .NET LINQ; verified on .NET 10.0.14
C#

Enumerable.Average: practical reference

Enumerable.Average: practical reference: Immediately enumerates numeric values and returns the mean in the overload-specific result type. Nullable overloads ignore null values.

Basic · .NET LINQ; verified on .NET 10.0.14
C#

Enumerable.Chunk: practical reference

Enumerable.Chunk: practical reference: Deferred enumeration groups consecutive elements into new arrays whose length is at most size. The final array can be shorter.

Basic · .NET 6+; verified on .NET 10.0.14
C#

Enumerable.Concat: practical reference

Enumerable.Concat: practical reference: The deferred result yields every element of the first source and then every element of the second, retaining duplicates.

Basic · .NET LINQ; verified on .NET 10.0.14
C#

Enumerable.Contains: practical reference

Enumerable.Contains: practical reference: Immediately enumerates to the first element equal to the sought value under the supplied IEqualityComparer<T> or EqualityComparer<T>.Default.

Basic · .NET LINQ; verified on .NET 10.0.14
C#

Enumerable.Count: practical reference

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>.

Basic · .NET LINQ; verified on .NET 10.0.14