CSharp · Console
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
List<Operation> operations = new List<Operation>
{
new Operation() { Name= "Exemplo 1", StartDate = DateTime.Now.AddDays(-1) },
new Operation() { Name = "Exemplo 2", StartDate =DateTime.Now.AddDays(-10) },
new Operation() { Name = "Exemplo 3", StartDate =DateTime.Now.AddDays(-20) },
new Operation() { Name = "Exemplo 4", StartDate =DateTime.Now.AddDays(-30) },
new Operation() { Name = "Exemplo 5", StartDate =DateTime.Now.AddDays(-45) },
new Operation() { Name = "Exemplo 6", StartDate =DateTime.Now.AddDays(-50) }
};
List<Operation> operationsDois = operations.Where(x => x.Name == "Exemplo 1" || x.Name == "Exemplo 2").ToList();
operationsDois.ForEach(p=> Console.WriteLine(p.Name));
}
}
public class Operation
{
public string Name { get; set; }
public DateTime StartDate { get; set; }
}