Yes, you can achieve the same by writing very simple LINQ query.
Code sample is given below:
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
Customer cust = new Customer();
List<Customer> custList = cust.GetCustomerData();
int matchedCount = custList.Where(p => p.Data1 == p.Data2).Count();
int unmatchedCount = custList.Where(p => p.Data1 != p.Data2).Count();
}
}
public class Customer
{
public int Id { get; set; }
public string Data1 { get; set; }
public string Data2 { get; set; }
public List<Customer> GetCustomerData()
{
return new List<Customer> {
new Customer () { Id = 1, Data1 = "A",Data2 = "B"},
new Customer () { Id = 2, Data1 = "C",Data2 = "C"},
new Customer () { Id = 3, Data1 = "D",Data2 = "D"},
new Customer () { Id = 1, Data1 = "B",Data2 = "A"},
new Customer () { Id = 1, Data1 = "C",Data2 = "D"},
new Customer () { Id = 1, Data1 = "A",Data2 = "A"},
new Customer () { Id = 1, Data1 = "A",Data2 = "B"},
new Customer () { Id = 1, Data1 = "D",Data2 = "D"}
};
}
}
}