The most efficient approach is using Enumerable.Join
:
var common = from x in GetTransDeta
join id in _GetRecCust
on int.Parse(x.Id) equals id
select id;
List<int> commonIDs = common.ToList();
By the way, why is Tranobject.Id
a string at all?
Edit: Since you have commented that there are null
s, you could use IsNullOrWhiteSpace
first:
var common = from x in GetTransDeta
where !string.IsNullOrWhiteSpace(x.Id)
join id in _GetRecCust
on int.Parse(x.Id) equals id
select id;