using System.Collections.Generic;
public static void Main()
List<NotaFiscal> notasExcel = GetNotasExcel();
List<NotaFiscal> notasConsisaNet = GetNotasConsisaNet();
List<string> chavesExcept = notasConsisaNet.Select(x => x.Chave).Except(notasExcel.Select(x=>x.Chave)).ToList();
List<NotaFiscal> notasExcept = notasConsisaNet.Where(x => chavesExcept.Contains(x.Chave)).ToList();
Console.WriteLine("Notas ConsisaNET:");
notasConsisaNet.ForEach(x => Console.WriteLine(x.Chave +", "+ x.Emitente+", "+ x.Total.ToString("C2")));
Console.WriteLine("".PadRight(50,'-'));
Console.WriteLine("Notas Excel:");
notasExcel.ForEach(x => Console.WriteLine(x.Chave +", "+ x.Emitente+", "+ x.Total.ToString("C2")));
Console.WriteLine("".PadRight(50,'-'));
chavesExcept.ForEach(x => Console.WriteLine("Chave está no Consisa e não está no excel: "+ x ));
notasExcept.ForEach(x => Console.WriteLine("Objeto Nota Fiscal que está no Consisa e não está no excel: "+ x.Chave +", "+ x.Emitente+", "+ x.Total.ToString("C2")));
public static List<NotaFiscal> GetNotasExcel()
List<NotaFiscal> notas = new List<NotaFiscal>();
notas.Add(new NotaFiscal(){ Chave = "123456ABC", Emitente = "Empresa A", Total = 10 });
notas.Add(new NotaFiscal(){ Chave = "223456DEF", Emitente = "Empresa B", Total = 20 });
notas.Add(new NotaFiscal(){ Chave = "423456JKL", Emitente = "Empresa D", Total = 40 });
notas.Add(new NotaFiscal(){ Chave = "623456PQR", Emitente = "Empresa F", Total = 60 });
notas.Add(new NotaFiscal(){ Chave = "723456STU", Emitente = "Empresa G", Total = 70 });
notas.Add(new NotaFiscal(){ Chave = "823456VWX", Emitente = "Empresa H", Total = 80 });
public static List<NotaFiscal> GetNotasConsisaNet()
List<NotaFiscal> notas = new List<NotaFiscal>();
notas.Add(new NotaFiscal(){ Chave = "123456ABC", Emitente = "Empresa A", Total = 10 });
notas.Add(new NotaFiscal(){ Chave = "223456DEF", Emitente = "Empresa B", Total = 20 });
notas.Add(new NotaFiscal(){ Chave = "323456GHI", Emitente = "Empresa C", Total = 30 });
notas.Add(new NotaFiscal(){ Chave = "423456JKL", Emitente = "Empresa D", Total = 40 });
notas.Add(new NotaFiscal(){ Chave = "523456MNO", Emitente = "Empresa E", Total = 50 });
notas.Add(new NotaFiscal(){ Chave = "623456PQR", Emitente = "Empresa F", Total = 60 });
notas.Add(new NotaFiscal(){ Chave = "723456STU", Emitente = "Empresa G", Total = 70 });
notas.Add(new NotaFiscal(){ Chave = "823456VWX", Emitente = "Empresa H", Total = 80 });
public string Chave {get;set;}
public string Emitente {get;set;}
public decimal Total {get;set;}