Mega Code Archive

 
Categories / C# Tutorial / LINQ
 

Ice Creams with price less than 10

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> icecreamsList = new List<Icecream>              {               new Icecream {Name="A", Price=10.5 },               new Icecream {Name="B", Price=9.80 },               new Icecream {Name="C", Price=7.5 }             };         IEnumerable<Icecream> i = from ice in icecreamsList where ice.Price < 10 select ice;         foreach (Icecream ice in i)         {             Console.WriteLine("{0} is {1}", ice.Name, ice.Price);         }     } } public class Icecream {     public string Name { get; set; }     public double Price { get; set; } }