步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)

[索引页]
[源码下载]


步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)、QuerySyntax(查询语法)和AnonymousTypes(匿名类型)


作者:webabcd


介绍
    ·LambdaExpressions(Lambda表达式)
    ·QuerySyntax(查询语法)
    ·AnonymousTypes(匿名类型)


示例
LambdaExpressions.cs(Lambda表达式)
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Data; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Configuration; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Linq; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Web; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Web.Security; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Web.UI; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Web.UI.WebControls; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Web.UI.WebControls.WebParts; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Web.UI.HtmlControls; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Xml.Linq; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Collections.Generic; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
/// <summary> 
/// LambdaExpressions(Lambda表达式)的摘要说明 
/// </summary> 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)public class LambdaExpressions 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)        public int ID { get; set; } 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)        public string Name { get; set; } 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)        public void LambdaExpressionsTest() 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)        { 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                List<LambdaExpressions> list = new List<LambdaExpressions> 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                { 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        new LambdaExpressions { ID = 1, Name = "webabcd" }, 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        new LambdaExpressions { ID = 2, Name = "webabcdefg" }, 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        new LambdaExpressions { ID = 3, Name = "webabcdefghijklmn" } 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                }; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                IEnumerable<LambdaExpressions> l = list.Where(le => le.Name == "webabcd"); 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                // 上面的(Lambda表达式)等同于下面的(匿名方法) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                // IEnumerable<LambdaExpressions> l2 = list.Where(delegate(LambdaExpressions le) { return le.Name == "webabcd"; }); 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                // 相关委托 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                // public delegate TResult Func<T, TResult>(T arg); 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)            
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                // 相关Where扩展方法 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                // Func<TSource, bool>:接受一个类型为TSource的参数 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                // Func<TSource, bool>:某个需要满足的条件,返回bool值 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                // public static IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                // { 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                //         foreach (TSource item in source) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                //         { 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                //                 if (predicate(item)) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                //                 { 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                //                         yield return item; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                //                 } 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                //         } 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                // } 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)        } 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)}
 

QuerySyntax.cs(查询语法)
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Data; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Configuration; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Linq; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Web; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Web.Security; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Web.UI; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Web.UI.WebControls; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Web.UI.WebControls.WebParts; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Web.UI.HtmlControls; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Xml.Linq; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Collections.Generic; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
/// <summary> 
/// QuerySyntax(查询语法)的摘要说明 
/// </summary> 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)public class QuerySyntax 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)        public int ID { get; set; } 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)        public string Name { get; set; } 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)        public void QuerySyntaxTest() 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)        { 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                List<QuerySyntax> list = new List<QuerySyntax> 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                { 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        new QuerySyntax { ID = 1, Name = "webabcd" }, 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        new QuerySyntax { ID = 2, Name = "webabcde" }, 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        new QuerySyntax { ID = 2, Name = "webabcdef" }, 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        new QuerySyntax { ID = 2, Name = "webabcdefg" }, 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        new QuerySyntax { ID = 2, Name = "webabcdefgh" }, 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        new QuerySyntax { ID = 2, Name = "webabcdefghi" }, 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        new QuerySyntax { ID = 2, Name = "webabcdefghij" }, 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        new QuerySyntax { ID = 2, Name = "webabcdefghijk" }, 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        new QuerySyntax { ID = 2, Name = "webabcdefghijkl" }, 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        new QuerySyntax { ID = 2, Name = "webabcdefghijklm" }, 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        new QuerySyntax { ID = 3, Name = "webabcdefghijklmn" } 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                }; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                IEnumerable<QuerySyntax> l = from o in list 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                                                                         where o.Name.Length > 10 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                                                                         orderby o.Name.Length descending 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                                                                         select o; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                // 上面的(查询语法)等同于下面的(LINQ扩展方法和Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                // 查询语法相对更容易理解 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                // IEnumerable<QuerySyntax> l = list.Where(o => o.Name.Length > 10).OrderByDescending(o => o.Name.Length); 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                // Projection(映射) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                // 可以返回一个新的类型 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                IEnumerable<Projection> l2 = from o in list 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                                                                            where o.Name.Length > 10 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                                                                            orderby o.Name.Length descending 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                                                                            select new Projection { Name = o.Name }; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)        } 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
/// <summary> 
/// 为了演示Projection(映射)而写的实体类 
/// </summary> 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)public class Projection 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)        public string Name { get; set; } 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)}
 
AnonymousTypes.cs匿名类型
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Data; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Configuration; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Linq; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Web; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Web.Security; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Web.UI; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Web.UI.WebControls; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Web.UI.WebControls.WebParts; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Web.UI.HtmlControls; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Xml.Linq; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)using System.Collections.Generic; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
/// <summary> 
/// AnonymousTypes(匿名类型)的摘要说明 
/// </summary> 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)public class AnonymousTypes 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)        public int ID { get; set; } 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)        public string Name { get; set; } 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)        public int Age { get; set; } 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)        public void AnonymousTypesTest() 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)        { 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                List<AnonymousTypes> list = new List<AnonymousTypes> 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                { 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        new AnonymousTypes { ID = 1, Name = "webabcd", Age = 10 }, 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        new AnonymousTypes { ID = 2, Name = "webabcdefg", Age = 20 }, 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        new AnonymousTypes { ID = 3, Name = "webabcdefghijklmn", Age = 30 } 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                }; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                // listAnonymousTypes - 匿名类型 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                var listAnonymousTypes = from l in list 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                                                                 where l.Name == "webabcd" 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                                                                 select new { Name = l.Name, Age = l.Age }; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                foreach (var v in listAnonymousTypes) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                { 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        // v - 匿名类型,可以在Visual Studio中得到编译时检查和完整的intellisense 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        string name = v.Name; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                        int age = v.Age; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                } 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式) 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                // 声明匿名类型:将new关键词后面的类型名称省略掉 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                var person = new { Name = "webabcd", Age = 27 }; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                // person - 匿名类型,可以在Visual Studio中得到编译时检查和完整的intellisense 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                string myName = person.Name; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)                int myAge = person.Age; 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)        } 
步步为营VS 2008 + .NET 3.5(4) - C# 3.0新特性之LambdaExpressions(Lambda表达式)}
 
 
 



     本文转自webabcd 51CTO博客,原文链接:http://blog.51cto.com/webabcd/344994,如需转载请自行联系原作者

上一篇:网络基础


下一篇:10年资深架构师谈Linux上容器背后的虚拟化解决方案