using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Linq;
using System.Linq;
using System.Collections;
class Car
{
public string PetName;
public string Color;
public int Speed;
public string Make;
}
class Program
{
static void Main(string[] args)
{
ArrayList myCars = new ArrayList();
myCars.Add(new Car{ PetName = "Henry", Color = "Silver", Speed = 100, Make = "BMW"});
myCars.Add(new Car{ PetName = "Clunker", Color = "Rust", Speed = 5, Make = "Yugo"});
myCars.Add(new Car { PetName = "Melvin", Color = "White", Speed = 43, Make = "Ford" });
IEnumerable<Car> myCarsEnum = myCars.OfType<Car>();
// Create a query expression.
var fastCars = from c in myCarsEnum where c.Speed > 55 select c;
foreach (var car in fastCars)
{
Console.WriteLine("{0} is going too fast!", car.PetName);
}
}
}
|