飞's profile年少,年少,行乐直须及早PhotosBlogGuestbookMore Tools Help

Blog


    January 03

    庐山三日自助游

          今年一直想远游,经过多次的计划,最后决定元旦庐山三日游。
          2008-12-30下午18:52, 2311 次列车 从上海南出发到九江,从九江上庐山最近。 但是该车是绿皮车,如果没有买到卧票,请不要考虑,否则极为痛苦,典型的脏乱差。坐我对面的一家人,一路狂吃,随地狂吐垃圾,还有2个小孩(张得真丑),恨不能使出飞龙腿踢飞他们。   
          次日,8:50到达九江,直接买回程票(从九江到上海南的票很难买,可以买到南昌的票,再到上海南,多费点银子)。刚出站,一标语把我囧到了。   
    由于前晚的折腾,我直接在火车站附近找了一家店住下了,这个决定是非常错误,火车站附近的店太黑了,大家以后吃住千万不要在火车站附近。
    九洲宾馆,我住的地方(100元/标间) 但是结账的时候居然收了毛巾费用24元(很黑啊~~~~)。在九江市内有很多住宿的,不用着急找住宿。
    稍作休息,就游览了九江市内(琵琶亭,潯阳楼,锁江楼,周瑜点将台,有5路公交直达,这的出租车很便宜,起步才5元)。其实没啥特别好玩的,完全可以忽略。晚上
    在九江市内随便找了一家餐馆,都还蛮便宜的,吃的比较辣。关键问题是没有看到PLMM。
         第2日早上,在火车站乘101,102公交去长途汽车站购买汽车票上庐山。车票12元/张,淡季最早7:50发车,1个小时一班。这是从正门上山的路,中途会有卖庐山的门票(138元/张,进庐山其他的景点另收门票,据说要改成联票了),如果是九江人,可以不用买票。(如果不想买票,还可以从其他门上山,不要从此路上山,可以找个本地人问问)开车的司机绝对是看头文字D看多了,一路都在玩漂移,晕车的人都要有准备了,(开车前都会有个小姑娘发送个袋子)。1个小时后来到牯岭镇,住宿的地点,也是游览庐山的出发点。刚下车,就有庐山导游跟踪了上来(非常烦人),不要理睬,自己找住宿就可以了(住宿的价格就看个人还价水平了)。
    我住宿的地方(120元/晚,国民党当时住宿的地方)
    安排好住宿,吃完早饭,就开始游庐山了。游庐山一线。该线是一条环线,从牯岭镇出发,再回到牯岭镇。买张地图,先到花径,过白居易草堂,再经过御碑亭,
    到达仙人洞。(此路线除了御碑亭到仙人洞有点看头,其他还不如南京的紫金山)从花径到仙人洞路程很短,就当散步好了。这是在去仙人洞的路上拍得,还不错。
     很多导游团带人到仙人洞就返回了,那就完全错过1线游了,还不如不来。从仙人洞接着走,途经文殊台,圆佛殿,到达龙首崖。(龙首崖很不错的风景)
     
    到了龙首崖,就可以到石门涧了,该景点也是要收费的(42元/张),该景点也是值得一看得,所以才会收费。(有人从这个景点上山,可以逃大门票,但是42还是要出的,然后按刚才的路线,到达牯岭镇)
     
    之所以这个景点值得一看,完全是因为之前的景点太无聊了。相对来说,算是很漂亮的了。从石门涧出发,有2条路可选,沿原路返回到牯岭镇或者在往前走
    到水电站大坝。在这有个停车场,到此之后后面的景色其实一般,完全可以坐车回镇。如果体力好或者省钱,也可以选择继续前行到庐山别墅区美然后返回。(由于是小路,最好问一下路)回镇后,就吃晚饭休息准备明天的2线了。
     
    提示:
    1。该线路程都比较好走,不用坐索道。如果时间不够,其实不游也没有关系。保留体力游2线。
    2。不要理上来搭讪的导游,很烦人。
    3。吃的东西一般,随便吃点就好了。
    4。镇上的超市不贵,特产干果不错,可以买点,特别是毕根果。
    5。住宿和坐车要砍价。
     
    休息了一晚,就开始2线游了,2线比较远,最好包车去。50元包车到含鄱口和五老峰。(如果要看日出,要到五老峰上面看,要很早,所以放弃了)
    镇上的人都比较懒散,到7:00超市还没有开门,可能是冬天的关系。7:30出发,8:00到达含鄱口。(含鄱口还有一些景点,自己选择是否要去)
    然后再来到五老峰,该山一定要爬,光在下面是体会不到其中的风光的。而且我有幸在山上看到了海市蜃楼。从一峰顺次爬到5峰开始下山。(或者从原路返回)
     从五老峰一直下直到三叠泉。这段路有点长,但是很幽静,可以慢慢体验一下。三叠泉也是要另收费的,51元/张,因为是冬天,可以看到冰川瀑布,非常地壮观。
     最后一路下山就可以到庐山东门了,到达庐山东门坐车到海会镇(5元/人),海会镇有中巴车直达九江火车站(5元/人)。
     
    提示:
    1。2线这3个景点一定要游玩
    2。如果不下山到九江,记得在山叠泉买返山标志。
    3。隔夜多积累体力,一路很耗体力。
     
     
    May 28

    赚钱

          从大学开始就想着要赚钱,因为有了钱就可以买自己想买的,吃自己想吃的,那时喜欢说“等我有了钱,如何如何”,但事实是什么钱都没有赚到。
    等到工作了,终于可以勉强自己维持生计了,改口说“等我赚了很多钱,如何如何”。
          我一直认为保持这样的信念,就一定可以赚到很多钱。但现实总是残酷的,这个念头除了能让自己安慰一下外,啥用都没有。真正会赚钱的人以赚钱
    为乐。而我仅仅是喜欢赚钱之后的享受罢了。
          赚钱之道很多,就是找不到。
    March 07

    定位

          做自己能做的,把虚无缥缈的目标放一边,增强自己的成就感.
    也许就有意外出现.
         先把能吃的吃了,能玩的玩的.
    February 19

    反省

         上海是个好地方,到处都有机会,到处都有诱惑。而我的心也开始变得浮躁和功利。以为自己什么都行,
    但仔细想想,却是能力有限。常常幻想中了500w,或者炒股赚了很多钱,但现实是我还是一个程序员,每天
    要写代码。静心想想,其实程序员的选择并不多,因为大部分时间都和机器打交道,不能产生多少变数。而且
    这行就像鸡肋一样,食之无味,弃之不舍。毕竟绝大部分人做不了比尔盖茨。唯一可以做的就是不断地学习,
    保证自己不被淘汰。拿着一份不高不低的薪水养家糊口。看看一些“出色”的前辈们,虽然心有不甘,但是不得
    不承认自己以后的路也就那样了,甚至还不如。在这些想法的推动下,心态开始了变化,迷茫,看不到出路,
    虽然知道这样不对,但又觉得无能为力。
        其实现在的一切,都是为自己在大学不努力买单。在大学里,好好学习其实是个很重要的事,但是却不紧急。
    我们往往只做紧急的事,而忽略重要的事。每过1年,回头看看,总觉得自己很忙,但是想想又没有做什么。重要
    的事不做,必然成为紧急的事。要强迫自己好好读书,否则2~3年后将为现在的不努力而买单。一时兴起不难,但
    坚持就很难。因为我们会去比较,羡慕某某出国,某某嫁(娶)了有钱人,在比较中迷失。
        我不能确定努力之后会有多大成就,但至少会比现在好。饭要一口一口吃,事要一件一件做,着急也没用。只要
    明天比今天好,这就是希望。我们虽然穷,但是我们不偷,不抢,好好读书,做一个对社会有贡献的人。
    February 01

    回看2007

           2007,一个折腾的年份,太多的事发生,以至于我都想不起到底发生了什么,也有可能是选择性失忆。这真是不错的选择。唯一可以记得的就是我在8月底换了新东家。就像卖菜一样,把自己给卖了,没想到猪肉比较贵,人不值钱。我不能确定是否这是个正确的决定,因为这个决定很仓促,也正是这次决定打乱了我的计划。所谓谋事在人,成事在天。我已做了我能做的,就等结果吧。
           现在我不断的提醒自己要低调,要冷静。
          我也不知道要写什么,就想打打字,太混乱了。还是祝大家新年快乐,08年重新来过。
     
    November 07

    C#3.0 Sepcification(中英对照) (十)

    26.7 Query expressions查询表达式

    Query expressions provide a language integrated syntax for queries that is similar to relational and hierarchical query languages such as SQL and XQuery.

    查询表达式为查询提供了一个类似于关系和分层的查询语言(SQLXQuery)的语言集成(译者: intergrated或译整合”)语法。

    query-expression:
    from-clause query-body
    from-clause:
    from from-generators
    from-generators:
    from-generator
    from-generators , from-generator
    from-generator:
    identifier in expression
    query-body:
    from-or-where-clausesopt orderby-clauseopt select-or-group-clause into-clauseopt
    from-or-where-clauses:
    from-or-where-clause
    from-or-where-clauses from-or-where-clause
    from-or-where-clause:
    from-clause
    where-clause
    where-clause:
    where boolean-expression
    orderby-clause:
    orderby ordering-clauses
    ordering-clauses:
    ordering-clause
    ordering-clauses , ordering-clause
    ordering-clause:
    expression ordering-directionopt
    ordering-direction:
    ascending
    descending
    select-or-group-clause:
    select-clause
    group-clause
    select-clause:
    select expression
    group-clause:
    group expression by expression
    into-clause:
    into identifier query-body

    A query-expression is classified as a non-assignment-expression, the definition of which occurs in §26.3.

    查询表达式作为非赋值(non-assignment-expression)表达式分类,其定义出现在§26.3

    A query expression begins with a from clause and ends with either a select or group clause. The initial from clause can be followed by zero or more from or where clauses. Each from clause is a generator that introduces an iteration variable ranging over a sequence, and each where clause is a filter that excludes items from the result. The final select or group clause specfies the shape of the result in terms of the iteration variable(s). The select or group clause may be preceded by an orderby clause that specifies an ordering for the result. Finally, an into clause can be used to “splice” queries by treating the results of one query as a generator in a subsequent query.

    查询表达式以from开始,结束于 selectgroup子句。开头的from子句可以跟随0个或者更多个fromwhere子句。每个from子句都是一个产生器,它引入了一个迭代变量在序列上搜索;每个where子句是一个过滤器,它从结果中排除一些项。最后的selectgroup子句指定了依据迭代变量得出的结果的外形 (shape)Selectgroup子句前面可有一个orderby子句,它指明返回结果的顺序。最后into子句可以通过把一条查询语句的结果作为产生器插进子序列查询中的方式来拼接查询。

    In a query expression, a from clause with multiple generators is exactly equivalent to multiple consecutive from clauses with a single generator.

    在查询表达式中,多个产生器的from子句正好等价于多个连续的带有单个产生器的from子句。

    C#3.0 Sepcification(中英对照) (九)

    26.6 Implicitly typed arrays隐型数组(Implicitly typed arrarys
    The syntax of array creation expressions (§7.5.10.2) is extended to support implicitly typed array creation expressions:
    扩展数组创建表达式(§7.5.10.2)的语法用以支持隐型数组创建表达式:
    array-creation-expression:

    new [ ] array-initializer
    In an implicitly typed array creation expression, the type of the array instance is inferred from the elements sp ecified in the array initializer. Specifically, the set formed by the types of the expressions in the array initializer must contain exactly one type to which each type in the set is implicitly convertible, and if that type is not the null type, an array of that type is created. If exactly one type cannot be inferred, or if the inferred type is the null type, a compile-time error occurs.
    在隐型数组创建表达式中,数组实例的类型推导自数组初始化器中元素的类型。特别地,数组初始化器中表达式类型形成的类型集合(set),必须包含一个这样的类型,其中每个类型都可隐式转型成它,并且这个类型不是null类型,如此,这个类型的数组就被创建了。如果不能推导出一个准确的类型,或者推导出的类型是空null类型,编译器错误就会出现。

    The following are examples of implicitly typed array creation expressions:
    下面是隐型数组创建表达式的例子:
    var a = new[] { 1, 10, 100, 1000 }; // int[]
    var b = new[] { 1, 1.5, 2, 2.5 }; // double[]
    var c = new[] { "hello", null, "world” }; // string[]
    var d = new[] { 1, "one", 2, "two" }; // Error
    The last expression causes a compile-time error because neither int nor string is implicitly convertible to the other. An explicitly typed array creation expression must be used in this case, for example specifying the type to be object[]. Alternatively, one of the elements can be cast to a common base type, which would then become the inferred element type.
    最后一个表达式导致编译器错误,这是因为intstring都不能隐式转换成对方。显型数组创建表达式必须这么使用:例如指定类型为object[]。另外,其中一个元素可以被转型到一个公共基类型,这个类型就会成为推导出的元素类型。

    Implicitly typed array creation expressions can be combined with anonymous object initializers to create anonymously typed data structures. For example:
    隐型数组创建表达式可以与匿名对象初始化器结合使用来创建匿名类型的数据结构。例如:
    var contacts = new[] {
    new {
    Name = "Chris Smith",
    PhoneNumbers = new[] { "206-555-0101", "425-882-8080" }
    },
    new {
    Name = "Bob Harris",
    PhoneNumbers = new[] { "650-555-0199" }
    }
    };

    C#3.0 Sepcification(中英对照) (八)

    26.5 Anonymous types匿名类型
    C# 3.0 permits the new operator to be used with an anonymous object initializer to create an object of an anonymous type.
    C# 3.0
    允许new操作符与匿名对象初始化器联用来创建一个匿名类型的对象。
    primary-no-array-creation-expression:

    anonymous-object-creation-expression
    anonymous-object-creation-expression:
    new anonymous-object-initializer
    anonymous-object-initializer:
    { member-declarator-listopt }
    { member-declarator-list , }
    member-declarator-list:
    member-declarator
    member-declarator-list , member-declarator
    member-declarator:
    simple-name
    member-access
    identifier = expression

    An anonymous object initializer declares an anonymous type and returns an instance of that type. An anonymous type is a nameless class type that inherits directly from object. The members of an anonymous type are a sequence of read/write properties inferred from the object initializer(s) used to create instances of the type. Specifically, an anonymous object initializer of the form
    匿名对象初始化器声明一个匿名类型并返回这个类型的实例。一个匿名类型是一个无名类(nameless class)(译者:参考jjhou先生的翻译具名(named)”),它直接继承自Object。匿名类型的成员是一系列推导自用于创建这个类型实例的对象初始化器的读/写属性。特别地,匿名对象初始化器具有如下形式:
    new { p1 = e1 , p2 = e2 , …pn = en }
    declares an anonymous type of the form
    它声明了一个如下形式的匿名类型
    class __Anonymous1
    {
    private T1f1 ;
    private T2f2 ;

    private Tnfn ;
    public T1p1 { get { return f1 ; } set { f1 = value ; } }
    public T2p2 { get { return f2 ; } set { f2 = value ; } }

    public T1p1 { get { return f1 ; } set { f1 = value ; } }
    }
    where each Tx is the type of the corresponding expression ex. It is a compile-time error for an expression in an anonymous o bject initializer to be of the null type.
    这里每个Tx是对应表达式ex的类型。匿名对象初始化器中的表达式是null类型是一个编译期错误。
    The name of an anonymous type is automatically generated by the compiler and cannot be referenced in program text.
    匿名类型的名字是由编译器自动产生的,在程序正文中不可被引用。
    Within the same program, two anonymous object initializers that specify a sequence of properties of the same names and types in the same order will produce instances of the same anonymous type. (This definition includes the order of the properties because it is observable and material in certain circumstances, such as reflection.)
    在同样的程序中,以相同顺序指定了一系列相同名字和类型的两个匿名对象初始化器将会产生相同匿名类型的实例。(这个定义包含了属性的次序,是因为它在某些环境中这是可观测和重要的,比如reflection
    In the example
    例子
    var p1 = new { Name = "Lawnmower", Price = 495.00 };
    var p2 = new { Name = "Shovel", Price = 26.95 };
    p1 = p2;
    the assignment on the last line is permitted because p1 and p2 are of the same anonymous type.
    最后一行的赋值是可行的,因为p1 p2具有相同的匿名类型。
    A member declarator can be abbreviated to a simple name (§7.5.2) or a member access (§7.5.4). This is called a projection initializer and is shorthand for a declaration of and assignment to a property with the same name. Specifically, member declarators of the forms
    成员声明符可以缩写成简单的名字(§7.5.2)或一个成员访问(§7.5.4)。这称为投射初始化器(projection initializer),是具备相同名字属性声明和赋值的速记方式。
    identifier expr . identifier
    are precisely equivalent to the following, respectively:
    分别等价于下面:
    identifer = identifier identifier = expr . identifier
    Thus, in a projection initializer the identifier selects both the value and the field or property to which the value is assigned. Intuitively, a projection initializer projects not just a value, but also the name of the value.
    因此,在投射初始化器中,identifier选择了被赋予值的值和域或属性。直观上,投射初始化器不仅投射值,也投射值的名字。

    C#3.0 Sepcification(中英对照)(七)

    26.4 Object and collection initializers对象和集合初始化器
    An object creation expression (§7.5.10.1) may include an object or collection initializer which initializes the members of the newly created object or the elements of the newly created collection.
    对象创建表达式(§7.5.10.1)可以包含一个对象或集合初始化器,用于初始化新创建的对象的成员或新创建的集合的元素。
    object-creation-expression:
    new type ( argument-listopt ) object-or-collection-initializeropt
    new type object-or-collection-initializer
    object-or-collection-initializer:
    object-initializer
    collection-initializer
    An object creation expression can omit the constructor argument list and enclosing parentheses provided it includes an object or collection initializer. Omitting the constructor argument list and enclosing parentheses is equivalent to specifying an empty argument list.
    对象创建表达式可以省略构造函数(译者:或译构造器”)(constructor)的参数列表和封闭的圆括号,而提供给它一个对象或集合初始化器。省略构造函数参数列表和封闭的圆括号等价于指定一个空参数列表。
    Execution of an object creation expression that includes an object or collection initializer consists of first invoking the instance constructor and then performing the member or element initializations specified by the object or collection initializer.
    包含对象或集合初始化器的对象创建表达式的执行包含首先调用实例构造函数,然后执行由对象或集合初始化器指定的成员或元素初始化动作。
    It is not possible for an object or collection initializer to refer to the object instance being initialized.
    对象或集合初始化器不能引用正被实例化的对象实例。
     
    *******************************************************************************************************
    26.4.1 Object initializers对象初始化器
    An object initialize r specifies values for one or more fields or properties of an object.
    对象初始化器指定一个或多个对象的域或属性的值。
    object-initializer:
    { member-initializer-listopt }
    { member-initializer-list , }
    member-initializer-list:
    member-initializer
    member-initializer-list , member-initializer
    member-initializer:
    identifier = initializer-value
    initializer-value:
    expression
    object-or-collection-initializer
    An object initializer consists of a sequence of member initializers, enclosed by { and } tokens and separated by commas. Each member initializer must name an accessible field or property of the object being initialized, followed by an equals sign and an expression or an object or collection initializer. It is an error for an object initializer to include more than one member initializer for the same field or property.
    对象初始化器由一系列成员初始化器组成,封闭于{}标记内并且由逗号间隔。每个成员初始化器必须指出正被初始化的对象的域或属性的名字,后面是等号”=” 表达式或者对象或集合的初始化器。
    A member initializer that specifies an expression after the equals sign is processed in the same way as an assignment (§7.13.1) to the field or property.
    在等号后面指定表达式的成员初始化器作为与对域或属性赋值同样的方式处理。
    A member initializer that specifes an object initializer after the equals sign is an initialization of an embedded object. Instead of assigning a new value to the field or property, the assignments in the object initializer are treated as assignments to members of the field or property. A property of a value type cannot be initialized using this construct.
    在等号后指定一个对象初始化器的成员初始化器是对内嵌对象的初始化。对象初始化器中的赋值作为域或属性成员的赋值对待,而不是给域或属性赋予新值。值类型的属性不可用这种构造方式初始化。
    A member initializer that specifies a collection initializer after the equals sign is an initialization of an embedded collection. Instead of assigning a new collection to the field or property, the elements given in the initializer are added to the collection referenced by the field or property. The field or property must be of a collection type that satisfies the requirements specified in §26.4.2.
    在等号后指定集合初始化器的成员初始化器是对内嵌集合的初始化。初始化器中给定的元素被加进域或属性引用的集合中,而不是给域或属性赋予新的集合。域或属性必须是满足§26.4.2中指定要求的集合类型。
    The following class represents a point with two coordinates:
    下面的类要求一个有两个坐标的point

    public class Point
    {
    int x, y;
    public int X { get { return x; } set { x = value; } }
    public int Y { get { return y; } set { y = value; } }
    }
    An instance of Point can be created an initialized as follows:
    Point
    的实例可以被创建和实例化如下:
    var a = new Point { X = 0, Y = 1 };
    which has the same effect as
    它等效于
    var a = new Point();
    a.X = 0;
    a.Y = 1;
    The following class represents a rectangle created from two points:
    下面的这个类表示由两个points构成的rectangle
    public class Rectangle
    {
    Point p1, p2;
    public Point P1 { get { return p1; } set { p1 = value; } }
    public Point P2 { get { return p2; } set { p2 = value; } }
    }
    An instance of Rectangle can be created and initialized as follows:
    Rectangle
    的实例可以被创建和初始化如下:
    var r = new Rectangle {
    P1 = new Point { X = 0, Y = 1 },
    P2 = new Point { X = 2, Y = 3 }
    };
    which has the same effect as
    它等效于
    var r = new Rectangle();
    var __p1 = new Point();
    __p1.X = 0;
    __p1.Y = 1;
    r.P1 = __p1;
    var __p2 = new Point();
    __p2.X = 2;
    __p2.Y = 3;
    r.P2 = __p2;
    where __p1 and __p2 are temporary variables that are otherwise invisible and inaccessible.
    这里__p1__p2是临时变量且是不可见和不可访问的。
    If Rectangle’s constructor allocates the two embedded Point instances
    如果Rectangle的构造函数分配了两个内嵌的Point的实例
    public class Rectangle
    {
    Point p1 = new Point();
    Point p2 = new Point();
    public Point P1 { get { return p1; } }
    public Point P2 { get { return p2; } }
    }
    the following construct can be used to initialize the embedded Point instances instead of assigning new instances:
    下面的构造可被用于初始化内嵌的Point实例,而不是赋予新的实例值。
    var r = new Rectangle {
    P1 = { X = 0, Y = 1 },
    P2 = { X = 2, Y = 3 }
    };
    which has the same effect as
    它等效于
    var r = new Rectangle();
    r.P1.X = 0;
    r.P1.Y = 1;
    r.P2.X = 2;
    r.P2.Y = 3;
     
    **************************************************************************
    26.4.2 Collection initializers集合初始化器
    A collection initializer specifies the elements of a collection.
    集合初始化器指定集合的元素。
    collection-initializer:
    { element-initializer-listopt }
    { element-initializer-list , }
    element-initializer-list:
    element-initializer
    element-initializer-list , element-initializer
    element-initializer:
    non-assignment-expression
    A collection initializer consists of a sequence of element initializers, enclosed by { and } tokens and separated by commas. Each element initializer specifies an element to be added to the collection object being initialized. To avoid ambiguity with member initializers, element initializers cannot be assignment expressions. The non-assignment-expression production is defined in §26.3.
    集合初始化器由一系列元素初始化器组成,封闭进 { } 标记内,以逗号间隔。每个元素初始化器指定一个将被加进正被初始化的集合对象中的元素。
    The following is an example of an object creation expression that includes a collection initializer:
    下面是对象创建表达式的例子,包含有一个集合初始化器:
    List digits = new List { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
    The collection object to which a collection initializer is applied must be of a type that implements System.Collections.Generic.ICollection for exactly one T. Furthermore, an implicit conversion (§6.1) must exist from the type of each element initializer to T. A compile-time error occurs if these requirements are not satisfied. A collection initializer invokes the ICollection.Add(T) method for each specified element in order.
    被应用了集合初始化器的集合对象必须是实现了正好一个类型TSystem.Collections.Generic.IConlection< T>的类型。此外必须存在从每个元素类型到T类型的隐式转型。如果这些条件都不满足,就产生编译期错误。集合初始化器对每个指定元素依次调用 ICollection.Add(T)方法。
    The following class represents a contact with a name and a list of phone numbers:
    下面的类表示一个名字和电话号码列表的contact
    public class Contact
    {
    string name;
    List phoneNumbers = new List();
    public string Name { get { return name; } set { name = value; } }
    public List PhoneNumbers { get { return phoneNumbers; } }
    }
    A List can be created and initialized as follows:
    List
    可以被创建和实例化如下:
    var contacts = new List {
    new Contact {
    Name = "Chris Smith",
    PhoneNumbers = { "206-555-0101", "425-882-8080" }
    },
    new Contact {
    Name = "Bob Harris",
    PhoneNumbers = { "650-555-0199" }
    }
    };
    which has the same effect as
    它等效于:
    var contacts = new List ();
    var __c1 = new Contact();
    __c1.Name = "Chris Smith";
    __c1.PhoneNumbers.Add("206-555-0101");
    __c1.PhoneNumbers.Add("425-882-8080");
    contacts.Add(__c1);
    var __c2 = new Contact();
    __c2.Name = "Bob Harris";
    __c2.PhoneNumbers.Add("650-555-0199");
    contacts.Add(__c2);
    where __c1 and __c2 are temporary variables that are otherwise invisible and inaccessible.
    这里__c1__c2是临时变量,不可见,也不可访问。

    C#3.0 Sepcification(中英对照)(六)

    26.3.3 Overload resolution重载决议
    Lambda expressions in an argument list affect overload resolution in certain situations.
    参数列表中的Lambda表达式在某些条件下影响重载决议。
    The following rule augments §7.4.2.3: Given a lambda expression L for which an inferred return type (§26.3.2) exists, an implicit conversion of L to a delegate type D1 is a better conversion than an implicit conversion of L to a delegate type D2 if D1 and D2 have identical parameter lists and the implicit conversion from L’s inferred return type to D1’s return type is a better conversion than the implicit conversion from L’s inferred return type to D2’s return type. If these conditions are not true, neither conversion is better.
    下面的规则要增加进§ 7.4.2.3:给定一个lambda表达式L,为其推导出的返回类型存在,如果delegate类型D1D2具有相同的参数列表,从LD1的隐式转型比从LD2的隐式转型更好;并且从L推导出的返回类型到D1返回类型的隐式转型比从L推导出的返回类型到D2返回类型的隐式转型更好。如果这些条件不为真,两者都不行。
    The following example illustrates the effect of this rule.
    下面的例子例示了这个规则的效果。
    class ItemList: List
    {
    public int Sum(Func selector) {
    int sum = 0;
    foreach (T item in this) sum += selector(item);
    return sum;
    }
    public double Sum(Func selector) {
    double sum = 0;
    foreach (T item in this) sum += selector(item);
    return sum;
    }
    }
    The ItemList class has two Sum methods. Each takes a selector argument, which extracts the value to sum over from a list item. The extracted value can be either an int or a double and the resulting sum is likewise either an int or a double.
    ItemList
    类有两个Sum方法。每个方法都有一个selector参数,方法从列表项中提取值累加进sum。提取的值可以是intdouble型,返回sum同样可以是intdouble型。
    The Sum methods could for example be used to compute sums from a list of detail lines in an order.
    Sum
    方法可以作为例子用于从detail列表中依次计算和。
    class Detail
    {
    public int UnitCount;
    public double UnitPrice;
    ...
    }
    void ComputeSums() {
    ItemList orderDetails = GetOrderDetails(...);
    int totalUnits = orderDetails.Sum(d => d.UnitCount);
    double orderTotal = orderDetails.Sum(d => d.UnitPrice * d.UnitCount);
    ...
    }
    In the first invocation of orderDetails.Sum, both Sum methods are applicable because the lambda expression d=>d.UnitCount is compatible with both Func and Func. However, overload resolution picks the first Sum method because the conversion to Func is better than the conversion to Func.
    orderDetails.Sum
    首次调用中,两个Sum方法都适用,这是因为lambda表达式d=>d.UnitCount兼容于Func Func这两者。然而,重载决议选择了第一个Sum方法,这是因为转换至Func好于转换至Func

    In the second invocation of orderDetails.Sum, only the second Sum method is applicable because the lambda expression d=>d.UnitPrice*d.UnitCount produces a value of type double. Thus, overload resolution picks the second Sum method for that invocation
    orderDetails.Sum
    的第二次调用中,仅仅第二个Sum方法适用,这是因为lambda表达式d=>d.UnitPrice*d.UnitCount产生的类型是double。因此重载决议为此调用选择了第二个方法。

    C#3.0 Sepcification(中英对照)(五)

    26.3.2 Type inference类型推导
    When a generic method is called without specifying type arguments, a type inference process attempts to infer type arguments for the call. Lambda expressions passed as arguments to the generic method participate in this type inference process.
    当泛型方法被调用而不指明类型参数时,参数推导过程试图从调用中推导出类型参数。Lambda表达式参数传递给泛型方法参与这个类型推导过程。
    As described in §20.6.4, type inference first occurs independently for each argument. In this initial phase, nothing is inferred from arguments that are lambda expressions. However, following the initial phase, additional inferences are made from lambda expressions using an iterative process. Specifically, inferences are made as long as one or more arguments exist for which all of the following are true:
    如同§20.6.4中表述的那样,类型推导首先为每个参数独立的发生。在初始阶段,不能从lambda表达式参数推导出任何东西。然而,初始阶段之后,产生了使用迭代过程的额外的推导。特别地,只要有一个或多个满足如下条件为真的参数存在,推导将会产生:
    · The argument is a lambda expression, in the following called L, from which no inferences have yet been made.
    ·
    参数是lambda表达式,下面称为L,从中,尚无推导。
    · The corresponding parameter’s type, in the following called P, is a delegate type with a return type that involves one or more method type parameters.
    ·
    相应的参数类型,下面称为P,是有返回类型的含有一个或多个方法类型参数的delegate
    · P and L have the same number of parameters, and each parameter in P has the same modifiers as the corresponding parameter in L, or no modifiers if L has an implicitly typed parameter list.
    · P
    L拥有相同数目的参数,并且P中的每个参数与L中相应的参数具有相同的修饰符,或者如果L有隐型参数列表时,没有修饰符。
    · P’s parameter types involve no method type parameters or involve only method type parameters for which a consistent set of inferences have already been made.
    · P
    的参数类型不包含方法类型参数或者包含仅仅一个方法类型参数,对这个参数已经产生一个相容的推导集。
    · If L has an explicitly typed parameter list, when inferred types are substituted for method type parameters in P, each parameter in P has the same type as the the corresponding parameter in L.
    ·
    如果L有一个显型参数列表,当推导出的类型对于P中的方法类型参数是可替换的时候,P中的每个参数拥有与L中对应的参数相同的类型。
    · If L has an implicitly typed parameter list, when inferred types are substituted for method type parameters in P and the resulting parameter types are given to the parameters of L, the body of L is a valid expression or statement block.
    ·
    如果L有一个隐型参数列表,当推导出的类型对于P中的方法类型参数是可替代的,并且返回参数类型被给予L的参数L的体是一个有效表达式或语句块。
    · A return type can be inferred for L, as described below.
    ·
    返回类型可以为L推导出来,描述如下:
    For each such argument, inferences are made from that argument by relating the return type of P with the inferred return type of L and the new inferences are added to the accumulated set of inferences. This process is repeated until no further inferences can be made.
    对每一个这样的参数,将会通过关联P的返回类型和L的推导返回类型做出推论,并且新的推论被加入进累积的推论集。这个过程将重复进行,直到没有更进一步的推论产生为止。
    For purposes of type inference and overload resolution, the inferred return type of a lambda expression L is determined as follows:
    因为类型推导和重载决议的原因,lambda表达式L推导出的类型决定于下面:
    · If the body of L is an expression, the type of that expression is the inferred return type of L.
    ·
    如果L的体是一个表达式,表达式的类型就是推导出的L的返回类型。
    · If the body of L is a statement block, if the set formed by the types of the expressions in the block’s return statements contains exactly one type to which each type in the set is implicitly convertible, and if that type is not the null type, then that type is the inferred return type of L.
    ·
    如果L的体是一个语句块,如果由语句块中return语句表达式的类型形成的集合(set)正好包含一个集合中每个类型都可隐式转换成的类型,那么这个类型就是推导出的L的返回类型。(译者:如果有个集合{int, byte, double},则double满足要求)
    · Otherwise, a return type cannot be inferred for L.
    ·
    此外,返回类型不能为L推导出来。

    As an example of type inference involving lambda expressions, consider the Select extension method declared in the System.Query.Sequence class:
    作为一个包含lambda表达式的类型推导的例子,考虑声明于System.Query.Sequence类中的Select扩展方法:
    namespace System.Query
    {
    public static class Sequence
    {
    public static IEnumerable  Select(

    this IEnumerable source,
    Func selector)
    {
    foreach (T element in source) yield return selector(element);
    }
    }
    }
    Assuming the System.Query namespace was imported with a using clause, and given a class Customer with a Name property of type string, the Select method can be used to select the names of a list of customers:
    假定System.Query名字空间使用using子句导入,并且给出一个类Customer,带有类型为string的属性Name, Select方法可用作选择一列(list of )customers的名字
    List customers = GetCustomerList();
    IEnumerable names = customers.Select(
    c => c.Name);
    The extension method invocation (§26.2.3) of Select is processed by rewriting the invocation to a static method invocation:
    Select
    扩展方法调用通过重写静态方法调用处理:

    IEnumerable names = Sequence.Select(customers, c => c.Name);
    Since type arguments were not explicitly specified, type inference is used to infer the type arguments. First, the customers argument is related to the source parameter, inferring T to be Customer. Then, using the lambda expression type inference process described above, c is given type Customer, and the expression c.Name is related to the return type of the selector parameter, inferring S to be string. Thus, the invocation is equivalent to
    因为类型参数未被显式指明,将会使用类型推导来推导类型参数。首先customers参数被关联到source参数,推导TCustomer。然后使用前面描述的lambda表达式类型推导过程, c是给定类型Customer,而表达式c.Name被关联到selector参数的返回类型上,推导sstring,这样,调用就等价于
    Sequence.Select(customers, (Customer c) => c.Name)
    and the result is of type IEnumerable.
    返回类型是IEnumerable
    The following example demonstrates how lambda expression type inference allows type information to “flow” between arguments in a generic method invocation. Given the method
    下面的例子示范了lambda表达式类型推导是如何允许类型信息在泛型函数调用的参数之间流动的。给出方法

    static Z F(X value, Func f1, Func f2) {
    return f2(f1(value));
    }
    type inference for the invocation
    调用的类型推导
    double seconds = F("1:15:30", s => TimeSpan.Parse(s), t => t.TotalSeconds);
    proceeds as follows: First, the argument "1:15:30" is related to the value parameter, inferring X to be string. Then, the parameter of the first lambda expression, s, is given the inferred type string, and the expression TimeSpan.Parse(s) is related to the return type of f1, inferring Y to be System.TimeSpan. Finally, the parameter of the second lambda expression, t, is given the inferred type System.TimeSpan, and the expression t.TotalSeconds is related to the return type of f2, inferring Z to be double. Thus, the result of the invocation is of type double.
    处理过程如下:首先参数”1:15:30”被关联到值参数,推导Xstring。然后第一个lambda表达式的参数s是给定推导类型string,并且表达式TimeSpan.Parse(s)被关联到f1的返回类型上,推导YSystem.TimeSpan最后第二个 lambda表达式的参数t,是给定为推导类型System.TimeSpan,表达式t.ToTalSeconds被关联到f2的返回类型上,推导Z double。这样,调用的返回类型就是double

    C#3.0 Sepcification(中英对照)(四)

    26.3 Lambda expressions Lambda表达式
    C# 2.0 introduces anonymous methods, which allow code blocks to be written “in-line” where delegate values are expected. While anonymous methods provide much of the expressive power of functional programming languages, the anonymous method syntax is rather verbose and imperative in nature. Lambda expressions provide a more concise, functional syntax for writing anonymous methods.
    C# 2.0
    引入了匿名方法,它允许在delegate(delegate value) (译者:delegate对象)被需要的地方以内联(in-line)方式写一个代码块。当匿名方法提供了大量函数式编程语言(或泛函编程) (functional programming)的表达力时,实质上,匿名方法的语法是相当烦琐和带有强制性的。Lambda表达式提供了一个更加简练的函数式语法来写匿名方法。


    A lambda expression is written as a parameter list, followed by the => token, followed by an expression or a statement block.
    Lambda

    表达式写成一个后面紧跟 => 标记的参数列表,=>之后是一个表达式或表语句块。
    expression:
    assignment
    non-assignment-expression
    non-assignment-expression:
    conditional-expression
    lambda-expression
    query-expression
    lambda-expression:
    ( lambda-parameter-listopt ) => lambda-expression-body
    implicitly-typed-lambda-parameter => lambda-expression-body
    lambda-parameter-list:
    explicitly-typed-lambda-parameter-list
    implicitly-typed-lambda-parameter-list
    explicitly-typed-lambda-parameter-list
    explicitly-typed-lambda-parameter
    explicitly-typed-lambda-parameter-list , explicitly-typed-lambda-parameter
    explicitly-typed-lambda-parameter:
    parameter-modifieropt type identifier
    implicitly-typed-lambda-parameter-list
    implicitly-typed-lambda-parameter
    implicitly-typed-lambda-parameter-list , implicitly-typed-lambda-parameter
    implicitly-typed-lambda-parameter:
    identifier
    lambda-expression-body:
    expression
    block


    The parameters of a lambda expression can be explicitly or implicitly typed. In an explicitly typed parameter list, the type of each parameter is explicitly stated. In an implicitly typed parameter list, the types of the parameters are inferred from the context in which the lambda expression occurs—specifically, when the lambda expression is converted to a compatible delegate type, that delegate type provides the parameter types (§26.3.1).
    Lambda
    表达式的参数可以是显型和隐型的。在显型参数列表中,每个参数的类型是显式指定的。在隐型参数列表中,参数的类型由lambda表达式出现的语境推导——特定地,当lambda表达式被转型到一个兼容的delegate类型时,delegate类型提供参数的类型(§26.3.1)


    In a lambda expression with a single, implicitly typed parameter, the parentheses may be omitted from the parameter list. In other words, a lambda expression of the form

    在有单一的隐型参数的lambda表达式中,圆括号可以从参数列表中省略。换句话说,如下形式的lambda表达式
    ( param ) => expr
    can be abbreviated to
    可以被简写成
    param => expr
    Some examples of lambda expressions follow below:
    下面是一些lambda表达式的例子:
    x => x + 1 // Implicitly typed, expression body
    x => { return x + 1; } // Implicitly typed, statement body
    (int x) => x + 1 // Explicitly typed, expression body
    (int x) => { return x + 1; } // Explicitly typed, statement body
    (x, y) => x * y // Multiple parameters
    () => Console.WriteLine() // No parameters


    In general, the specification of anonymous methods, provided in §21 of the C# 2.0 Specification, also applies to lambda expressions. Lambda expressions are a functional superset of anonymous methods, providing the following additional functionality:

    通常,C# 2.0规范§21中提供的匿名方法规范,也应用上了lambda表达式。Lambda表达式是匿名方法的泛函超集,它提供了如下附加功能:
    · Lambda expressions permit parameter types to be omitted and inferred whereas anonymous methods require parameter types to be explicitly stated.
    · Lambda
    表达式允许参数类型被省略掉和被推导,尽管匿名方法要求显式指定参数类型。
    · The body of a lambda expression can be an expression or a statement block whereas the body of an anonymous method can only be a statement block.
    · Lambda
    表达式体可以是一个表达式或者语句块,尽管匿名方法体可以是一个语句块。
    · Lambda expressions passed as arguments participate in type argument inference (§26.3.2) and in method overload resolution (§26.3.3).
    · Lambda
    表达式作为参数传递参与类型参数推导(§26.3.2)和重载决议。
    · Lambda expressions with an expression body can be converted to expression trees (§26.8).
    ·
    带有表达式体的Lambda表达式可以被转换成表达式树(§26.8)


    Note
    The PDC 2005 Technology Preview compiler does not support lambda expressions with a statement block body. In cases where a statement block body is needed, the C# 2.0 anonymous method syntax must be used.

    注意

    PDC 2005
    技术预览编译器不支持带有语句体的lambda表达式。在需要语句体的情况下,必须使用C# 2.0匿名方法语法。

    26.3.1 Lambda expression conversions Lambda
    表达式转换
    Similar to an anonymous-method-expression, a lambda-expression is classified as a value with special conversion rules. The value does not have a type but can be implicitly converted to a compatible delegate type. Specifically, a delegate type D is compatible with a lambda-expression L provided:
    与匿名方法表达式(anonymous-method-expression)类似,lambda表达式是用特殊转换规则作为值(value)类型分类的。这个值(value)没有类型,但是可以隐式转型至一个兼容的delegate类型。特别地,delegate类型D lambda表达式L兼容的,如果:
    · D and L have the same number of parameters.
    · D
    L有相同数目的参数。
    · If L has an explicitly typed parameter list, each parameter in D has the same type and modifiers as the corresponding parameter in L.
    ·
    如果L有显型参数列表,D中的每个参数有着与相应的L中的参数相同的类型和修饰符。
    · If L has an implicitly typed parameter list, D has no ref or out parameters.
    ·
    如果L有隐型参数列表,D不可有refout参数。
    · If D has a void return type and the body of L is an expression, when each parameter of L is given the type of the corresponding parameter in D, the body of L is a valid expression that would be permitted as a statement-expression (§8.6).
    ·
    如果Dvoid 返回类型,并且L的体(body)是一个表达式,当L的每个参数被给定为对应的D中参数的类型时,L的体是一个允许作为语句-表达式(statement-expression(§8.6))的有效表达式
    · If D has a void return type and the body of L is a statement block, when each parameter of L is given the type of the corresponding parameter in D, the body of L is a valid statement block in which no return statement specifies an expression.
    ·
    如果Dvoid返回类型并且L的体是语句块,当L的每个参数类型是被给定为相应的D参数的类型时,L的体是一个没有返回语句的有效语句块· If D has a non-void return type and the body of L is an expression, when each parameter of L is given the type of the corresponding parameter in D, the body of L is a valid expression that is implicitly convertible to the return type of D.
    ·
    如果Dnon-void返回值并且L的体是一个表达式,当L的每个参数类型是被给定的相应于D参数的类型时,L的体是一个可以隐式转换到D返回类型的有效表达式。

    · If D has a non-void return type and the body of L is a statement block, when each parameter of L is given the type of the corresponding parameter in D, the body of L is a valid statement block with a non-reachable end point in which each return statement specifies an expression that is implicitly convertible to the return type of D.
    ·
    如果Dnon-void返回值并且L的体是一个语句块,当L的每个参数类型是被给定的相应于D参数的类型时,L的体是一个有效的语句块,语句块中有不可到达(non-reachable)的终点(end point)(译者:是否应该为没有不可到达的终点”),且每个终点的返回语句指明一个可以隐式转换到D返回类型的表达式。


    The examples that follow use a generic delegate type Func which represents a function taking an argument of type A and returning a value of type R:

    下面的例子使用泛型delegagte类型Func表示一个带有参数类型A和返回类型R的函数:
    delegate R Func(A arg);
    In the assignments
    赋值如下:
    Func f1 = x => x + 1; // Ok
    Func f2 = x => x + 1; // Ok
    Func f3 = x => x + 1; // Error
    the parameter and return types of each lambda expression are determined from the type of the variable to which the lambda expression is assigned. The first assignment successfully converts the lambda expression to the delegate type Func because, when x is given type int, x+1 is a valid expression that is implicitly convertible to type int. Likewise, the second assignment successfully converts the lambda expression to the delegate type Func because the result of x+1 (of type int) is implicitly convertible to type double. However, the third assignment is a compile-time error because, when x is given type double, the result of x+1 (of type double) is not implicitly convertible to type int.
    每个 Lambda表达式的参数和返回类型决定于lambda表达式被赋值的变量的类型。第一个赋值成功地转换lambda表达式到delegate类型 Func,是因为当 xint型,x+1 是一个有效的表达式并可以隐式地转换到类型int。同样第二个赋值成功地转换lambda表达式到delegate类型Func,是因为x+1的返回值(类型int)是隐式转换成double的。然而第三个赋值有编译期错误,因为当xdoublex+1 double,不能够隐式转变到类型int

     

    C#3.0 Sepcification(中英对照)(三)

    26.2 Extension methods扩展方法
    Extension methods are static methods that can be invoked using instance method syntax. In effect, extension methods make it possible to extend existing types and constructed types with additional methods.
    扩展方法是可以通过使用实例方法语法调用的静态方法。效果上,扩展方法使得用附加的方法扩展已存在类型和构造类型成为可能。

    Note
    Extension methods are less discoverable and more limited in functionality than instance methods. For those reasons, it is recommended that extension methods be used sparingly and only in situations where instance methods are not feasible or possible.
    Extension members of other kinds, such as properties, events, and operators, are being considered but are currently not supported.
    注意

    扩展方法不容易被发现并且在功能上比实例方法更受限。由于这些原因,推荐保守地使用和仅在实例方法不可行或不可能的情况下使用。
    其它种类的扩展方法,比如属性、事件和操作符,正在被考虑当中,但是当前并不被支持。


    ************************************************************************************
    26.2.1 Declaring extension methods
    声明扩展方法

    Extension methods are declared by specifying the keyword this as a modifier on the first parameter of the methods. Extension methods can only be declared in static classes. The following is an example of a static class that declares two extension methods:
    扩展方法是通过指定关键字this修饰方法的第一个参数而声明的。扩展方法仅可声明在静态类中。下面是声明了两个扩展方法的静态类的例子:
    namespace Acme.Utilities
    {
    public static class Extensions
    {
    public static int ToInt32(this string s) {
    return Int32.Parse(s);
    }
    public static T[] Slice(this T[] source, int index, int count) {
    if (index < 0 || count < 0 || source.Length – index < count)
    throw new ArgumentException();
    T[] result = new T[count];
    Array.Copy(source, index, result, 0, count);
    return result;
    }
    }
    }
    Extension methods have all the capabilities of regular static methods. In addition, once imported, extension methods can be invoked using instance method syntax.
    扩展方法具备所有常规静态方法的所有能力。另外,一旦被导入,扩展方法可以使用实例方法语法调用之。

     

    **********************************************************************************************************************
    26.2.2 Importing extension methods

    导入扩展方法
    Extension methods are imported through using-namespace-directives (§9.3.2). In addition to importing the types contained in a namespace, a using-namespace-directive imports all extension methods in all static classes in the namespace. In effect, imported extension methods appear as additional methods on the types that are given by their first parameter and have lower precedence than regular instance methods. For example, when the Acme.Utilities namespace from the example above is imported with the using-namespace-directive
    扩展方法用using-namespace- directives (§9.3.2)导入。除了导入包含在名字空间中的类型外,using-namespace-directives 也导入了名字空间中所有静态类中的所有扩展方法。实际上,被导入的扩展方法作为被修饰的第一个参数类型上的附加方法出现,并且相比常规实例方法具有较低的优先权。比如,当使用using-namespace-directive导入上个例子中Acme.Utilities 名字空间:
    using Acme.Utilities;


    it becomes possible to invoke the extension methods in the static class Extensions using instance method syntax:

    它使得可以在静态类Extension上使用实例方法语法调用扩展方法:

    string s = "1234";
    int i = s.ToInt32(); // Same as Extensions.ToInt32(s)
    int[] digits = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    int[] a = digits.Slice(4, 3); // Same as Extensions.Slice(digits, 4, 3)

    *******************************************************************************************************************
    26.2.3 Extension method invocations
    扩展方法调用
    The detailed rules for extension method invocation are described in the following. In a method invocation (§7.5.5.1) of one of the forms
    扩展方法调用的详细规则表述如下。以如下调用形式之一:
    expr . identifier ( )
    expr . identifier ( args )
    expr . identifier < typeargs > ( )
    expr . identifier < typeargs > ( args )


    if the normal processing of the invocation finds no applicable instance methods (specifically, if the set of candidate methods for the invocation is empty), an attempt is made to process the construct as an extension method invocation. The method invocation is first rewritten to one of the following, respectively:

    如果调用的正常处理过程发现没有适用的实例方法(特别地,如果这个调用的候选方法集是空的),就会试图处理扩展方法调用的构造。方法调用会首先被分别重写称如下之一:
    identifier ( expr )
    identifier ( expr , args )
    identifier < typeargs > ( expr )
    identifier < typeargs > ( expr , args )


    The rewritten form is then processed as a static method invocation, except for the way in which identifier is resolved: Starting with the closest enclosing namespace declaration, continuing with each enclosing namespace declaration, and ending with the containing compilation unit, successive attempts are made to process the rewritten method invocation with a method group consisting of all accessible extension methods with the name given by identifier imported by the namespace declaration’s using-namespace-directives. The first method group that yields a non-empty set of candidate methods is the one chosen for the rewritten method invocation. If all attempts yield empty sets of candidate methods, a compile-time error occurs.

    重写后的形式然后被作为静态方法调用处理,除非标识符 identifier决议为:以最靠近的封闭名字空间声明开始,以每个封闭名字空间声明继续,并以包含的编译单元结束,持续地试图用组成所有可访问的,由 using-namespace-directives导入的,指明为 identifier名字的扩展方法处理重写的方法调用。第一个产生非空候选方法集的方法组(method group)就成为被选中的重写的方法调用。如果所有的努力都只产生空的候选集,则发生编译期错误。


    The preceeding rules mean that instance methods take precedence over extension methods, and extension methods imported in inner namespace declarations take precedence over extension methods imported in outer namespace declarations. For example:
    前面的规则标表明实例方法优先于扩展方法,并且导入进内层名字空间中的扩展方法优先于导入进外层名字空间中的扩展方法。例如:
    using N1;
    namespace N1
    {
    public static class E
    {
    public static void F(this object obj, int i) { }
    public static void F(this object obj, string s) { }
    }
    }
    class A { }
    class B
    {
    public void F(int i) { }
    }

    class C
    {
    public void F(object obj) { }
    }
    class X
    {
    static void Test(A a, B b, C c) {
    a.F(1); // E.F(object, int)
    a.F("hello"); // E.F(object, string)
    b.F(1); // B.F(int)
    b.F("hello"); // E.F(object, string)
    c.F(1); // C.F(object)
    c.F("hello"); // C.F(object)
    }
    }
    In the example, B’s method takes precedence over the first extension method, and C’s method takes precedence over both extension methods.
    例子中,B的方法优先于第一个扩展方法,C的方法优先于两个扩展方法。

    C#3.0 Sepcification(中英对照)(二)

    26.1 Implicitly typed local variables隐型局部变量
    In an implicitly typed local variable declaration, the type of the local variable being declared is inferred from the expression used to initialize the variable. When a local variable declaration specifies var as the type and no type named var is in scope, the declaration is an implicitly typed local variable declaration. For example:
    在隐型局部变量声明中,正被声明的局部变量的类型从初始化这个变量的表达式推导得来。当局部变量声明指明var作为类型,并且该范围域(scope)中没有var名称的类型存在,这个声明就称为隐型局部声明。例如:
    var i = 5;
    var s = "Hello";
    var d = 1.0;
    var numbers = new int[] {1, 2, 3};
    var orders = new Dictionary();


    The implicitly typed local variable declarations above are precisely equivalent to the following explicitly typed declarations:

    上面的隐型局部变量声明精确地等同于下面的显型(explicitly typed)声明:
    int i = 5;
    string s = "Hello";
    double d = 1.0;
    int[] numbers = new int[] {1, 2, 3};
    Dictionary orders = new Dictionary();


    A local variable declarator in an implicitly typed local variable declaration is subject to the following restrictions:
    隐型局部变量声明中的局部变量声明符(declarator)遵从下面这些约束:
    · The declarator must include an initializer.
    ·
    声明符必须包含初始化器。
    · The initializer must be an expression. The initializer cannot be an object or collection initializer (§26.4) by itself, but it can be a new expression that includes an object or collection initializer.
    ·
    初始化器必须是一个表达式。初始化器不能是一个自身的对象或者集合初始化器(26.4),但是它可以是包含一个对象或集合初始化器的一个new表达式。
    · The compile-time type of the initializer expression cannot be the null type.
    ·
    初始化器表达式的编译期类型不可以是空(null)类型。
    · If the local variable declaration includes multiple declarators, the initializers must all have the same compile-time type.
    ·
    如果局部变量声明包含了多个声明符,这些声明符必须具备同样的编译期类型。


    The following are examples of incorrect implicitly typed local variable declarations:

    下面是一些不正确的隐型局部变量声明的例子:
    var x; // Error, no initializer to infer type from
    var y = {1, 2, 3}; // Error, collection initializer not permitted
    var z = null; // Error, null type not permitted


    For reasons of backward compatibility, when a local variable declaration specifies var as the type and a type named var is in scope, the declaration refers to that type; however,a warning is generated to call attention to the ambiguity. Since a type named var violates the established convention of starting type names with an upper case letter, this situation is unlikely to occur.

    因为向后兼容的原因,当局部变量声明指定var作为类型,而范围域中又存在叫var的类型,则这个声明会推导为那个叫var的类型;然后,会产生一个关注含糊性(ambiguity)的警告,因为叫var 的类型违反了既定的类名首字母大写的约定,这个情形也未必会出现。(译者:视编译器实现而定)

    The for-initializer of a for statement (§8.8.3) and the resource-acquisition of a using statement (§8.13) can be an implicitly typed local variable declaration. Likewise, the iteration variable of a foreach statement (§8.8.4) may be declared as an implicitly typed local variable, in which case the type of the iteration variable is inferred to be the element type of the collection being enumerated. In the example
    for
    表达式(§8.8.3)for初始化器(for-initializer) using表达式的资源获取(resource-acquisition)可以作为一个隐型局部变量声明。同样,foreach表达式(§8.8.4) 的迭代变量可以声明为一个隐型局部变量,这种情况下,(隐型局部变量的)类型推导为正被枚举(enumerated)的集合的元素的类型。例子:

    int[] numbers = { 1, 3, 5, 7, 9 };
    foreach (var n in numbers) Console.WriteLine(n);
    the type of n is inferred to be int, the element type of numbers.
    n
    的类型推导为numbers的元素类型int

    C#3.0 Sepcification(中英对照)(一)

    2005 Microsoft Corporation. All rights reserved.
    Microsoft, Windows, Visual Basic, Visual C#, and Visual C++ are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries/regions.
    Other product and company names mentioned herein may be the trademarks of their respective owners.[/quote]

    Table of Contents 目录

    26. Overview of C# 3.0
    C# 3.0 概述)
    26.1 Implicitly typed local variables
    隐型局部变量(Implicity typed local variables)
    26.2 Extension methods
    扩展方法

    26.2.1 Declaring extension methods
    声明扩展方法
    26.2.2 Importing extension methods
    导入扩展方法
    26.2.3 Extension method invocations
    扩展方法的调用
    26.3 Lambda expressions Lambda
    表达式
    26.3.1 Lambda expression conversions Lambda
    表达式转换
    26.3.2 Type inference
    类型推导
    26.3.3 Overload resolution
    重载决议
    26.4 Object and collection initializers
    对象和集合的初始化器
    26.4.1 Object initializers
    对象初始化器
    26.4.2 Collection initializers
    集合初始化器

    26.5 Anonymous types 匿名类

    26.6 Implicitly typed arrays 隐型数组(Implicitly typed arrays)
    26.7 Query expressions
    查询表达式

    26.7.1 Query expression translation
    查询表达式的转换
    26.7.1.1 where clauses where
    子句
    26.7.1.2 select clauses select
    子句

    26.7.1.3 group clauses group子句
    26.7.1.4 orderby clauses orderby
    子句
    26.7.1.5 Multiple generators
    多重产生器(generator)
    26.7.1.6 into clauses info
    子句

    26.7.2 The query expression pattern
    查询表达式模式
    26.7.3 Formal translation rules
    正式的转换规则
    26.8 Expression trees
    表达式树

     ******************************************************************************************

     

    26. Overview of C# 3.0 (C# 3.0概述)
    C# 3.0 (“C# orcas”) introduces several language extensions that build on C# 2.0 to support the creation and use of higher order, functional style class libraries. The extensions enable construction of compositional APIs that have equal expressive power of query languages in domains such as relational databases and XML. The extensions include:
    C# 3.0 (“C#
    魔兽(Orcas)”) 引入了几个构建在C# 2.0上的语言扩展,用来支持创建和使用更高级的函数式(functional或译:泛函)
    类库。

    这些扩展允许组合(compositional) APIs的构造,这些APIs与关系数据库和XML等领域中的查询语言具有同等的表达力。

     

    · Implicitly typed local variables, which permit the type of local variables to be inferred from the expressions used to initialize them.
    ·
    隐型局部变量,允许局部变量的类型从初始化它们的表达式推导而来。


    · Extension methods, which make it possible to extend existing types and constructed types with additional methods.
    ·

    扩展方法,使得使用附加(additional)的方法扩展已存在的类型和构造类型成为可能。


    · Lambda expressions, an evolution of anonymous methods that provides improved type inference and conversions to both delegate types and expression trees.
    · Lambda

    表达式,是匿名方法的演进,可提供改良的类型推导和到dalegate类型和表达式树的转换。


    · Object initializers, which ease construction and initialization of objects.
    ·
    对象初始化器,简化了对象的构造和初始化。


    · Anonymous types, which are tuple types automatically inferred and created from object initializers.
    ·

    匿名类型,是从对象初始化器自动推导和创建的元组(tuple)类型。


    · Implicitly typed arrays, a form of array creation and initialization that infers the element type of the array from an array initializer.
    ·

    隐型数组,数组创建和初始化的形式,它从数组初始化器推导出数组的元素类型。


    · Query expressions, which provide a language integrated syntax for queries that is similar to relational and hierarchical query languages such as SQL and XQuery.
    ·

    查询表达式,为类似于关系型和层次化查询语言(比如SQLXQuery)提供一个语言集成(intergrated)的语法。


    · Expression trees, which permit lambda expressions to be represented as data (expression trees) instead of as code (delegates).
    ·

    表达式树,允许lambda表达式表示为数据(表达式树)而不是代码(delegate)


    This document is a technical overview of those features. The document makes reference to the C# Language Specification 1.2 (§1 through §18) and the C# Language Specification 2.0 (§19 through §25), both of which are available on the C# Language Home Page (http://msdn.microsoft.com/vcsharp/language).
    本文档是这些特征的技术概述。文档引用了C#语言规范1.2§1-§18)和C#语言规范2.0§19-§25),这两个规范都在C#语言主页上(http://msdn.microsoft.com/vcsharp/language)

    November 05

    程序人生

          努力工作,懈怠,跳槽,努力工作... 
          这是一个循环,何时才能break,无人知晓。 
          
          不写了,少说话,多做事,没事就去多睡觉。
    September 11

    接龙游戏 FROM Crystal

    首先先COPY一下游戏规则:

    一、被點到名字得要就是把所有的问题像我一样回答出来发一篇日志在自己的页面上。所有的问题都要答。写一篇我这样的日志。最后提一个自己的问题。再点出另外八个人继续回答~~~列出其他8個需要回答問題的人的名字,還要到這8個人的博客裏留言通知對方——你被點名了,被點名者不得拒絕回答問題。

    二、這8个人要在自己的博客裏注明是從哪裏接到的,並且再想一個問題傳給其他8個人,讓遊戲繼續下去,不得回傳。被點到名字的人將會得到大家的祝福,並且所有美好的願望都會在不久的將來實現。

           Crystal 的问题一定要回答的,加上刚上班没有多少事,就慢慢答。
          

    1、你上次哭是为什么?

        不能说。

     

    2、如果让你用生命换一个愿望,你会许什么?

          让我周围的朋友们都很富有。

     

    3你已经和你最爱的人在一起了吗 ? 并且相信会一直走下去吗? 

       没有。

       

     

    4、如果让你选择一种水果来形容我,你会选择什么呢? 

       柠檬。 

     

    5、你如何看待"原罪"?   

       有很多激情戏,不错。

     

    6黛玉和宝钗你更欣赏谁?

       都不欣赏,因为我都得不到。

     

    7你觉得现在什么对你是最重要的?

       钱。

     

    8、你会为别人改变自己吗?

       会,如果我认为值得。

     

    9、觉得自己是个好男人或者好女人吗?为什么?

            我觉得自己是个好男人,因为我不是好女人,总要选个答案的。

     

    10、请自己选一种死法,(安乐死除外)

        上吊,据资料(天涯资料)称,会很爽的。

     

    11、在你的眼里,什么是永恒的? 

        没有办法回头的事。

     

    12、到了2008,你会结婚么?

        不出意外是不会的。

     

    13、如果你结婚~会选择什么地方?

        地球,因为区外太空的费用太高了。

     

    14、你的下一个旅游地点想好了吗?   

        成都。

     

    15、在你眼中,我的缺点是什么? 

        不好说,容易引起社会不和谐。

     

    16、你会为了你最爱的人坚持么?即使他()不爱你 

        不爱我,我就放手。

     

    17、你认为友情和爱情怎样相处才能保持一辈子新鲜?

        互相理解,你认为新鲜就是新鲜。关键在于个人的手段。

     

    18、觉得爱情和友情经得起考验吗?  

              取决于考验的力度。

     

    19、你觉得女生是直发好还是卷发好?(不许回答说因人而异)

        直发。

     

    202008年奥运会开幕式门票你买哪种?200/800/1500/5000/     

             当然是5000,如果买的起,如果有人给我买更好。

     

    21、嘻嘻你的绰号和小名叫什么? 

             绰号:飞哥,还有其他的,不能说

             小名:小飞。

     

    22、悲伤的时候选择什么为自己治疗?

             沉默,喝酒。

     

    23、你认为我会不会得到幸福?

        会啊。你已经得到了,你会得到更多的。

     

    24、说一说经历过的最好和最变态的老师吧!

        最好的老师,幼儿园的一位老师,我迟到了,没骂我,还给我吃早饭。

        没有最BT,只有更BT.  

     

    25、到现在为止,最能温暖你的人是?

        不一定,可能是某句话,但不会具体到某个人。

     

    26、你喜欢下雨天吗?呵呵~说说理由吧~ 

             喜欢,可以躺在家里听雨声,然后睡觉,心里不会有罪恶感。 

     

    27、你对自己的未来有信心吗?有何打算?

              有信心。打算太长了,省略1000字。

     

    28、你想一个人住么?为什么?

        想,清静。

     

    29:如果你有小孩了,你希望是男生还是女生?为什么咧?

        男生啊。可以用来打,教他干坏事(不违反法律)。

     

    30、最怕的动物,为什么

        蛇,不为什么。

     

    31、你觉得是男人穷可悲!还是女人丑可悲!

        都可悲。

     

    32、承诺是个什么东西?

              就是我一定要做到的事。

     

    33,最近关心什么人,事,物?        

          最关心我父母,我朋友,会不会失业,会不会一辈子打光棍。

     
    34、你是一个能坚持的人吗?如何坚持做完一件事?
            是。强迫自己去做。
     
    35、我家宝宝生下来后,你们都准备些什么礼物啊!!(哈哈,绝吧) 
           这个问题太头疼了,买套衣服给你宝宝,让他可以挂在你身上,或者那种可以用来当拖把用的。
     
    我的问题
    36。2007年,你们请我吃饭呢还是请我出去玩(费用都由你们买单)?(两者必选其一)
     
     
    点名点名,冲最后一个问题,我也要点完8个。
    1.TT
    2.B刀
    3.大宝
    4.Angle
    5.qika
    6.贱人
    7.无双月
    8.b光
     
    August 15

    离去

    离去

         
         离,忍不住说出。
         不在6月,7月,因为等待已过期。
         仰起头,天亦蓝,一切依旧。
         留一点遗憾,我只身打马过汐。
        
         劝说,不忍拒绝。
         黎明的一丝白亮,让我心清。
         离一些人远了,离一些人就近。
         用心跳来离开。
       
         8月8,立秋,天凉,利西方。
     
    August 04

    转载三毛经典语录

    人生妙语录

    ▲在我的生活里,我就是主角。
    ▲对于他人的生活,我们充其量只是一份暗示、一种鼓励、启发、还有真诚的关爱。这些态度,可能因而丰富了他人的生活,但这没有可能发展为——代办他人的生命。我们当不起完全为另一个生命而活――即使他人给予这份权利。
    ▲过分为己,是为自私自利。完全舍我,也是虐待了一个生灵——自己。
    ▲不要害怕拒绝他人,如果自己的理由出于正当。当一个人开口提出要求的时候,他的心里根本预备好了两种答案。所以,给他任何一个其中的答案,都是意料中的。
    ▲我当心的去关爱他人,这使情感不流于泛滥。
    ▲我决不过分对人热络,这使我掌握分寸。
    ▲我漠视无谓的闲言,这使我内心舒畅。
    ▲我很少开口求人,这使我自由。
    ▲我不欠钱,这使我安心。
    ▲我让人欠我的钱,这使我做傻瓜。
    ▲我看书,这使我多活几度生命。
    ▲我哭,因为我爱。
    ▲我笑,因为不能不笑呀!
    ▲一个不欣赏自己的人,是难以快乐的。

    爱情妙录

    ▲爱情有如甘霖,没有了它,干裂的心田,即使撒下再多的种子,终是不可能滋发萌芽的生机。
    ▲世界上难有永恒的爱情,世上绝对存在永恒不灭的亲情,一旦爱情化解为亲情,那份根基,才不是建筑在沙土上了。
    ▲某些人的爱情,只是一种“当时的情绪”。如果对方错将这份情绪当做长远的爱情,是本身的幼稚。
    ▲一刹真情,不能说那是假的。爱情永恒,不能说只有那一刹。
    ▲爱情,如果不落实到穿衣、吃饭、数钱、睡觉这些实实在在的生活里去,是不容易天才地久的。
    ▲爱情不是必需,少了它心中却也荒凉。荒凉日子难过。难过的岂止是爱情?
    ▲爱情是一种奥妙,在爱情中出现籍口时,籍口就是籍口,显然已经没有热情的籍口而已,来无影,去无踪。如果爱情消逝,一方以任何理由强求再得,这,正如强收覆水一样的不明事理。
    ▲爱情是彩色气球,无论颜色如何艳丽,经不起针尖轻轻一刺。
    ▲逢场作戏,连儿戏都不如,这种爱情游戏只有天下最无聊的人才会去做。要是真有性情,认真办一次家家酒,才叫好汉烈女。
    ▲爱情的滋味复杂,绝对值得一试二尝三醉。
    友情妙语录
    ▲朋友是五伦之外的一种人际关系,一定要求朋友共生共死的心态,是因为人,没有界定清楚这一个名词的含意。
    ▲一刹知心的朋友,是贵在于短暂,拖长了,那份契合总有枝节。
    ▲朋友还是必须分类的——例如图书,一架一架混不得。过分混杂,匆忙中急着着,往往找错类别。
    ▲朋友再亲密,分寸不可差失,自以为熟,结果反生隔离。
    ▲朋友之义,难在义字千变万化。
    ▲朋友绝对落时空,儿时玩伴一旦阔别,再见时,情感只是一种回忆中的承诺,见面除了话当年以外,再说什么都难了。
    ▲朋友之间,相求小事,顺水人情,理当成全。过分要求,得寸进尺,是存心丧失朋友最快得捷径。
    ▲朋友共乐,锦上添花绝对有必要。朋友共苦,除非同病相怜,不然总有高低。
    ▲强占友谊,最是不聪明,雪泥鸿爪,碰着当成一场欢喜。一旦失去朋友,最豁达的想法莫如——本来谁也不是谁的。
    ▲可进可出,若即若离,可爱可怨,可聚而不会散,才是最天长地久的一种好朋友。

     

    July 21

         今天是周六,我破天荒的起这么早,原因是被吓醒的。噩梦,一个接一个的噩梦。昏昏沉沉地睡着了,又被吓醒。感觉是如此的真实,仿佛就像自己看电影一样,几乎让我精疲力尽。
         我现在醒着,但是悲伤的感觉还在延续,我自己都不知道为什么。我在努力回忆着我在梦里看到了什么。我唯一记得的就是我回家了,我离开了上海,我在上海混了2年,一无所得。还有很多,但是都很破碎。真的是日有所思,夜有所梦。所有的不快乐在瞬间爆发,在梦中几乎让我崩溃。看了看手机,8:15,很安静,有打电话的冲动,算了,不要扰人。
         终于平静了点,也许我该休息下了。