using System.Xml.Linq;
public class Example
{
public static void Main()
{
Console.Write("<< DistinctBy 예제 >> \n");
List<Car> cars = new List<Car>();
cars.Add(new Car() { CarCode = 1, CarType = 101 });
cars.Add(new Car() { CarCode = 1, CarType = 101 });
cars.Add(new Car() { CarCode = 2, CarType = 101 });
cars.Add(new Car() { CarCode = 3, CarType = 102 });
cars.Add(new Car() { CarCode = 3, CarType = 102 });
IEnumerable<Car> distinctCars = cars.DistinctBy(car => car.CarCode);
foreach(var item in distinctCars)
{
Console.WriteLine(item.CarCode);
}
Console.WriteLine(System.Environment.NewLine);
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
public class Car
{
public int CarCode { get; set; }
public int CarType { get; set; }
}