C Linq 查詢過濾 where()

2021-10-08 18:57:32 字數 1029 閱讀 9663

參考部落格。

要點:where()有兩個原型。【把滑鼠點到where,按下f12就可以轉到原型處】

1、public static ienumerablewhere(this ienumerablesource, funcpredicate);

2、public static ienumerablewhere(this ienumerablesource, funcpredicate);

例子:

static void main(string args)

;int sum0 = nums.sum();

console.writeline("the sum of all:", sum0);//所有資料的和

int sum1 = nums.where(n=>n%4==0).sum();

console.writeline("the sum of all:", sum1);//所有是4的倍數的資料的和

int sum2 = nums.where((n, i) => i % 2 == 0).sum();//10 + 30 + 50

console.writeline("the sum of all:", sum2);//所有下標是4的倍數的資料的和

}

執行結果如下: 

再看where()的兩個原型

1、public static ienumerablewhere(this ienumerablesource, funcpredicate);

2、public static ienumerablewhere(this ienumerablesource, funcpredicate);

注釋:source指資料來源、集合或者陣列名字,tsource是集合中資料型別;predicate表示篩選函式,該函式用來指定元素滿足的條件。int對應的是資料在陣列中的下標(如果source有的話),bool是func的返回值型別???(待確認)

MySQL中的查詢過濾條件where

and,or,not between and 別名表示式 首先建立乙個表並新增如下資料,在下述查詢中均用到此表 create table student id char 36 primary key,name varchar 8 not null,age int 3 default 0,mobile...

Hive array欄位 查詢過濾

如果乙個hive 表的乙個字段 是array型別,裡面存在多個值,如果要對其中的某個值進行過濾,那麼可以用lateral view 結合udtf user defined table generating functions 來進行過濾 lateral view語法 lateralview late...

BOS查詢過濾總集

驗證客戶名稱是否唯一 throws bo ception throws sqlexception private void isuniquename throws bo ception,sqlexception if prmtcustomernumber.getvalue null if custo...