var list1 = new String[] {"ABC1","ABC2", "ABC3", "ABC4"} ;
var list2 = new String[] {"ABC3","ABC4", "ABC5", "ABC6"} ;
var list3 = list1.Except(list2); // list3 holds ABC1, ABC2
Except works fine.
I suspect issue is in the item returned from the linq query.
Seems like f.BeerNames in first, and f in StoreList are not pointing to same datatype.
For heterogenous type
var list1 = from s in new String[] {"ABC1","ABC2", "ABC3", "ABC4"} select new {BeerName=s,Id = Guid.NewGuid().ToString()} ;
var list2 = new String[] {"ABC3","ABC4", "ABC5", "ABC6"} ;
var intermediateList = list1.Select(i=>i.BeerName).Except(list2);
var list3 = from l1 in list1
join l2 in intermediateList on l1.BeerName equals l2
select l1;
list1.Dump(); // run in linqPad
intermediateList.Dump();// run in linqPad
list3.Dump();// run in linqPad
list3 returns following
BeerName Id
ABC1 569ace9a-66c4-46aa-bbf5-50d586a2886f
ABC2 af456094-9692-4771-b489-8b3cca8aa938
Use LinqPad to run the above, or remove .Dump() to execute in VS.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…