I’ve been looking briefly at the latest C# 3.0 specification and all I can say is that reading some of those LINQ examples hurt my eyes.

Seriously, who wants to read code that looks like this? What does it do?

public void Linq19() {
    List customers = GetCustomerList();

    var customerOrders =
            (cust, custIndex) =>
            cust.Orders.Select(o => "Customer #" + (custIndex + 1) +
                                    " has an order with OrderID " + o.OrderID) );


I have the same problem with C# 3.0 that I have with Perl. It’s easy to forget what some of the unfamiliar operators do.

I’m disappointed that they aren’t making use of the yield operator and anonymous functions for this stuff instead. I would prefer to read code like this instead (note that this is using a pseudo C# 2.0-syntax):

ICollection result = Collection< String >.Create(
    foreach (c in customers)
      foreach (o in c.orders)
        yield "Customer #" + c.ID + " has an order with OrderID " + o.OrderID; 

A bunch of examples like this are available here.

Read full post