M_Cyjb_ArrayUtil_Fill__1_5 - CYJB/Cyjb GitHub Wiki

ArrayUtil.Fill(T) 方法 (T[], Func(Int32, T), Int32, Int32)

将数组从指定的索引位置开始使用指定的函数的返回值填充指定的长度。

Namespace: Cyjb
Assembly: Cyjb (in Cyjb.dll) Version: 1.0.23+7750dd8e971297c5fa962a3bee37fb78f72793f6

语法

C#

public static T[] Fill<T>(
	this T[] array,
	Func<int, T> value,
	int startIndex,
	int count
)

参数

 

array
Type: T[]
要填充的数组。
value
Type: System.Func(Int32, T)
返回要填充数组指定索引的值的函数,其参数是当前填充到的索引。
startIndex
Type: System.Int32
要开始填充的起始索引。
count
Type: System.Int32
要填充的数组元素个数。

类型参数

 

T
数组中元素的类型。

返回值

Type: T[]
填充完毕的数组。

备注

在 Visual Basic 和 C# 中,这个方法可以当成为类型的实例方法来调用。在采用实例方法语法调用这个方法时,请省略第一个参数。请参考 扩展方法 (Visual Basic)扩展方法 (C# 编程指南) 获取更多信息。

Exceptions

 

异常 条件
ArgumentNullException arraynull
ArgumentOutOfRangeException startIndexcount 之和大于数组的长度。
ArgumentOutOfRangeException startIndexcount 小于零。

参见

Reference

ArrayUtil 类
Fill 重载
Cyjb 命名空间

⚠️ **GitHub.com Fallback** ⚠️