using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using System.Xml.Linq;
class Program
{
static void Main(string[] args)
{
List<Icecream> icecreamsList3 = new List<Icecream>{
new Icecream("A", 10.5),
new Icecream("B", 9.80 ),
new Icecream("C", 7.5)
};
var icecreamswithLeastPrice =from Ice in icecreamsList3 where Ice.price <= 10 select new { Ice.name, Ice.price };
foreach (var ice in icecreamswithLeastPrice)
{
Console.WriteLine(ice.name + " " + ice.price);
}
var count = icecreamsList3.Count<Icecream>(Ice => Ice.price <= 10);
Console.WriteLine(count);
}
}
public class Icecream
{
public string name;
public double price;
public Icecream(string name, double price)
{
this.name = name;
this.price = price;
}
}