static void Main(string[] args)
{
List<PingReply> PingReplies = new List<PingReply> {
new PingReply { Status = 1 },
new PingReply { Status = 1 },
new PingReply { Status = 1 },
new PingReply { Status = 8 },
new PingReply { Status = 8 },
new PingReply { Status = 8 },
new PingReply { Status = 8 },
new PingReply { Status = 8 }
};
IEnumerable<PingReply> lastFive = PingReplies.Take(5);
int num = lastFive.Where(a => a.Status != 1).Count(); //shows 2
if (lastFive.Where(a => a.Status != 1).Count() == 5)
{
Console.WriteLine(" may be down");
}
Console.ReadLine();
}
private class PingReply
{
public int Status { get; set; }
}