C#数组中的TrueForAll()方法
使用TrueForAll()数组中的method,您可以检查每个元素的条件。
让我们看一个例子-
示例
using System;
using System.Text;
public class Demo {
public static void Main() {
int[] val = { 97, 45, 76, 21, 89, 45 };
//检查所有数组元素是否都超过一个
bool result = Array.TrueForAll(val, res => res > 1);
Console.WriteLine(result);
}
}输出结果
True
使用TrueForAll()数组中的method,您可以检查每个元素的条件。
让我们看一个例子-
示例
using System;
using System.Text;
public class Demo {
public static void Main() {
int[] val = { 97, 45, 76, 21, 89, 45 };
//检查所有数组元素是否都超过一个
bool result = Array.TrueForAll(val, res => res > 1);
Console.WriteLine(result);
}
}输出结果
True
热门推荐
10 同学分开祝福语简短
11 幼儿住院祝福语老师简短
12 哥哥结婚的祝福语简短
13 五二零朋友祝福语大全简短
14 哥哥新婚祝福语创意简短
15 牛年佛家祝福语大全简短
16 培训送别祝福语简短的话
17 新年祝福语大全简短老师
18 送给同桌的祝福语简短