Linq C# (一)
来源:互联网 发布:亿和数据 编辑:程序博客网 时间:2024/04/30 15:50
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LinqToSql.HR;
namespace LinqToSql
{
class Program
{
public static void Main(string[] args)
{
Cityes();
}
public static void Cityes()
{
string[] cities = new string[]{
"Hubei","henan","bejing","shanghai","guangzhou","sichuan","chongqiang","wulumoqi","henglongjiang"
};
IEnumerable<string> s1 = System.Linq.Enumerable.Where(cities, n => n.Length > 7);
foreach (string di in s1)
Console.WriteLine(di);
Console.WriteLine();
IEnumerable<string> s2 = cities.Where(n => n.Length > 7);
foreach (String di in s2)
Console.WriteLine(di);
Console.WriteLine();
IEnumerable<string> s3 = from n in cities
where n.Length > 7
select n;
foreach (string di in s3)
Console.WriteLine(di);
Console.WriteLine();
var filds = from n in cities
where n.Length > 7
select n;
foreach (string xx in filds)
{
Console.WriteLine(xx);
}
Console.WriteLine();
IEnumerable<string> s4 = cities.Where(new Func<string, bool>(Func2));
foreach (string d in s4)
Console.WriteLine(d);
Console.WriteLine();
IEnumerable<string> s5 = cities.Where<string>(new Func<string, bool>(Func2));
foreach (string d in s5)
Console.WriteLine(d);
Console.WriteLine();
IEnumerable<string> s6 = System.Linq.Enumerable.Where<string>(cities, new Func<string, bool>(Func2));
foreach (string d in s6)
Console.WriteLine(d);
Console.WriteLine();
IEnumerable<string> s7=cities.Where<string>(
delegate(string n){
return n.Length >7;
}
);
foreach (string d in s7)
Console.WriteLine(d);
Console.WriteLine();
}
public static bool Func2(string n)
{
return n.Length > 7;
}
}
}
- Linq C# (一)
- C# LINQ详解(一)
- C# LINQ详解(一)
- C#知识复习之linq(一)
- C# 高级特性(一) LINQ
- C#如何使用LINQ查询数据(一)
- LINQ&EF任我行(一)--C#3.0与LinQ
- Linq 学习(一)
- LINQ查询(一)
- linq(一)
- Linq实例(一)
- Linq 介绍(一)
- LINQ读书笔记(一)
- Linq 查询 (一)
- LINQ体验(一)LINQ to Object
- Linq学习笔记(一) -- 初识Linq
- LinQ学习笔记(一)
- LINQ学习(一)基本概念
- 动态数组
- think in baidu
- scanf 的特殊用法
- 开发U盘的几点体会[转]
- 两笔记本通过无线连接共享上网
- Linq C# (一)
- jsp : element 标签
- 整合Struts2+JasperReport Web报表应用示例
- think in google
- 使用JasperReport与iBATIS开发Web报表
- 情感——网络教育中不可缺少的组成部分
- 疯狂的程序员74
- 抽象类和抽象方法
- 含有多个列的ListView的赋值