linux-packaging-mono/mcs/tests/gtest-lambda-22.cs
Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

31 lines
583 B
C#

using System.Linq;
//
// This is a lambda test for situation when parent is infering return types and child not
//
public class Product
{
public int CategoryID;
public decimal UnitPrice;
}
class MainClass
{
public static void Main ()
{
Product[] products = new[] {
new Product { CategoryID = 1, UnitPrice = 1m }
};
var categories = from p in products
group p by p.CategoryID into g
select new {
g,
ExpensiveProducts = from p2 in g
where (p2.UnitPrice > g.Average (p3 => p3.UnitPrice))
select p2
};
}
}