Edit

Share via


Array.Fill Method

Definition

Overloads

Fill<T>(T[], T)

Assigns the given value of type T to each element of the specified array.

Fill<T>(T[], T, Int32, Int32)

Assigns the given value of type T to the elements of the specified array that are within the range of startIndex (inclusive) and the next count number of indices.

Fill<T>(T[], T)

Source:
Array.cs
Source:
Array.cs
Source:
Array.cs

Assigns the given value of type T to each element of the specified array.

C#
public static void Fill<T>(T[] array, T value);

Type Parameters

T

The type of the elements in the array.

Parameters

array
T[]

The array to be filled.

value
T

The value to assign to each array element.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1

Fill<T>(T[], T, Int32, Int32)

Source:
Array.cs
Source:
Array.cs
Source:
Array.cs

Assigns the given value of type T to the elements of the specified array that are within the range of startIndex (inclusive) and the next count number of indices.

C#
public static void Fill<T>(T[] array, T value, int startIndex, int count);

Type Parameters

T

The type of the elements of the array.

Parameters

array
T[]

The array to be filled.

value
T

The new value for the elements in the specified range.

startIndex
Int32

A 32-bit integer that represents the index in array at which filling begins.

count
Int32

The number of elements to copy.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1