Enumerable.All<(Of <(TSource>)>) 方法

Enumerable.All<(Of <(TSource>)>) 方法

确定序列中的所有元素是否满足条件。

 语法

public static bool<TSource>(

    this IEnumerable<TSource> source,

    Func<TSource, bool> predicate

)

类型参数

TSource

source 中的元素的类型。

参数

source

类型:System.Collections.Generic.IEnumerable<(Of <(TSource>)>)
包含要应用谓词的元素的 IEnumerable<(Of <(T>)>)

predicate

类型:System.Func<(Of <(TSource, Boolean>)>)
用于测试每个元素是否满足条件的函数。

返回值

类型:System.Boolean
如果源序列中的每个元素都通过指定谓词中的测试,或者序列为空,则为 true;否则为 false

使用说明

Visual Basic C# 中,可以在 IEnumerable<(Of <(TSource>)>) 类型的任何对象上将此方法作为实例方法来调用。当使用实例方法语法调用此方法时,请省略第一个参数。

 

 

     public   class  LinqAll
    {
        
public   static   void  Show( object  obj)
        {
            HttpContext.Current.Response.Write(
" <BR> "   +  obj.ToString());
        }

        
public   static   void  AllDemo()
        {
            
int [] nums  =   new   int [] {  1 2 3 4 5 6 7 8 9 10  };
            
bool  tag  =  nums.All((i)  =>  {  return  i  >   8 ; });
            Show(tag);

            var strs 
=   new [] {  " a " " b " " c " " d "  };
            tag 
=  strs.All < string > ((s)  =>  { LinqAggregate.Show(s);  return  s.ToCharArray()[ 0 >   75 ; });
            Show(tag);
        }
    }
调用:
    
protected   void  Page_Load( object  sender, EventArgs e)
    {
        LinqAll.AllDemo();
    }
结果:
  False
  a
  b
  c
  d
  True 

 

 

转载于:https://www.cnblogs.com/keely/archive/2010/06/23/1763701.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值