var sizelist= (from p in stockList select p.Size).Distinct().ToArray(); newslist = newslist.OrderBy(x=>x.nID).Distinct();var canuselist = entitylist.OrderByDescending(x => x.id).GroupBy(r => r.gpsdevicenum).Select(r => r.First()).ToList();