1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 5 public class Program 6 { 7 public static void Main() 8 { 9 var inputDtos = new List(){ 10 new Dto{ fname = "11", lname = "12", age = "13", gender = "1"}, 11 new Dto{ fname = "", lname = "12", age = "13", gender = "1"}, 12 new Dto{ fname = null, lname = "12", age = "13", gender = "1"}, 13 new Dto{ fname = "11", lname = "", age = "13", gender = "1"}, 14 new Dto{ fname = "11", lname = null, age = "13", gender = "1"}, 15 new Dto{ fname = "11", lname = "12", age = "", gender = "1"}, 16 new Dto{ fname = "11", lname = "12", age = null, gender = "1"}, 17 new Dto{ fname = "11", lname = "12", age = "13", gender = ""}, 18 new Dto{ fname = "11", lname = "12", age = "13", gender = null}, 19 20 new Dto{ fname = "11", lname = "12", age = "13", gender = "1"}, 21 new Dto{ fname = "21", lname = "22", age = "23", gender = "0"}, 22 new Dto{ fname = "21", lname = "22", age = "23", gender = "0"}, 23 24 25 }; 26 var DuplicateList = (from d in inputDtos 27 group d by 28 new 29 { 30 firstName = TrimValueSpace(d.fname), 31 lastName = TrimValueSpace(d.lname), 32 birthday = TrimValueSpace(d.age), 33 gender = TrimValueSpace(d.gender) 34 } 35 into gr 36 where gr.Count() > 1 37 && !string.IsNullOrWhiteSpace(gr.Key.firstName) 38 && !string.IsNullOrWhiteSpace(gr.Key.lastName) 39 && !string.IsNullOrWhiteSpace(gr.Key.birthday) 40 && !string.IsNullOrWhiteSpace(gr.Key.gender) 41 select gr.Key).ToList(); 42 43 if (DuplicateList != null ) 44 { 45 Console.WriteLine("ok --- " + DuplicateList.Count); 46 47 } 48 var sfdfd = "222"; 49 50 Console.WriteLine(sfdfd ?? "0"); 51 52 53 } 54 55 private static string TrimValueSpace(string value) 56 { 57 if (string.IsNullOrWhiteSpace(value)) 58 { 59 return string.Empty; 60 } 61 else 62 { 63 return value.Replace(" ", string.Empty).Replace(" ", string.Empty); 64 } 65 } 66 67 } 68 public class Dto{ 69 public string fname {get; set;} 70 public string lname {get; set;} 71 public string age{get; set;} 72 public string gender{get; set;} 73 }