Click here to Skip to main content
15,908,274 members
Home / Discussions / C#
   

C#

 
AnswerRe: Comparing 2 lists Pin
BobJanova8-Sep-11 3:29
BobJanova8-Sep-11 3:29 
That's what the selection on list2 will give. (Think about it for a moment.)

What you want is something along the lines of
var matches = list1.Where(x => list2.Contains(x));


Since you apparently want a value comparison you should override Equals (and maybe == too) on Emp. That would test that all the properties matched (and I think it would make Contains work in the above expression).

If you really want to check that any of the properties match, you need to write a Contains equivalent (it's a one line LINQ expression). But that seems unlikely.

Ideally you'd be using the same actual object for what appears to be a reference to the same database row, but if it's actually coming out of a database provider that may not be possible. Classes that represent database entities often want value semantics for equality (unless you're using some clever entity management framework that gives you the same instance for the same row).
AnswerRe: Comparing 2 lists Pin
Wayne Gaylard8-Sep-11 4:08
professionalWayne Gaylard8-Sep-11 4:08 
AnswerRe: Comparing 2 lists Pin
Daniel.Grondal8-Sep-11 21:46
Daniel.Grondal8-Sep-11 21:46 
QuestionUploading already use file Pin
sarang_k8-Sep-11 1:34
sarang_k8-Sep-11 1:34 
AnswerRe: Uploading already use file Pin
BobJanova8-Sep-11 1:49
BobJanova8-Sep-11 1:49 
GeneralRe: Uploading already use file Pin
sarang_k8-Sep-11 2:11
sarang_k8-Sep-11 2:11 
GeneralRe: Uploading already use file Pin
MicroVirus8-Sep-11 5:00
MicroVirus8-Sep-11 5:00 
GeneralRe: Uploading already use file Pin
BobJanova8-Sep-11 6:12
BobJanova8-Sep-11 6:12 
GeneralRe: Uploading already use file Pin
Eddy Vluggen8-Sep-11 6:53
professionalEddy Vluggen8-Sep-11 6:53 
GeneralRe: Uploading already use file Pin
BobJanova8-Sep-11 10:25
BobJanova8-Sep-11 10:25 
GeneralRe: Uploading already use file Pin
Eddy Vluggen8-Sep-11 10:34
professionalEddy Vluggen8-Sep-11 10:34 
GeneralRe: Uploading already use file Pin
MicroVirus8-Sep-11 13:07
MicroVirus8-Sep-11 13:07 
QuestionDirectShowNET Framework 4.0 and 2.0 Pin
semixor8-Sep-11 1:10
semixor8-Sep-11 1:10 
AnswerRe: DirectShowNET Framework 4.0 and 2.0 Pin
Eddy Vluggen8-Sep-11 7:00
professionalEddy Vluggen8-Sep-11 7:00 
GeneralRe: DirectShowNET Framework 4.0 and 2.0 Pin
semixor8-Sep-11 9:01
semixor8-Sep-11 9:01 
AnswerRe: DirectShowNET Framework 4.0 and 2.0 Pin
Eddy Vluggen8-Sep-11 9:11
professionalEddy Vluggen8-Sep-11 9:11 
QuestionIBasicVideo + NullRenderer ( How ? ) Pin
semixor8-Sep-11 0:50
semixor8-Sep-11 0:50 
AnswerRe: IBasicVideo + NullRenderer ( How ? ) Pin
MicroVirus8-Sep-11 4:49
MicroVirus8-Sep-11 4:49 
GeneralRe: IBasicVideo + NullRenderer ( How ? ) Pin
semixor8-Sep-11 5:52
semixor8-Sep-11 5:52 
GeneralRe: IBasicVideo + NullRenderer ( How ? ) Pin
MicroVirus8-Sep-11 13:28
MicroVirus8-Sep-11 13:28 
GeneralRe: IBasicVideo + NullRenderer ( How ? ) Pin
semixor9-Sep-11 3:20
semixor9-Sep-11 3:20 
QuestionDeep Linking between views when using PRISM Pin
Phillip Donegan7-Sep-11 21:46
Phillip Donegan7-Sep-11 21:46 
QuestionEF Repository Questions Pin
Matt U.7-Sep-11 11:00
Matt U.7-Sep-11 11:00 
GeneralRe: EF Repository Questions Pin
PIEBALDconsult7-Sep-11 18:10
mvePIEBALDconsult7-Sep-11 18:10 
GeneralRe: EF Repository Questions Pin
Matt U.8-Sep-11 2:35
Matt U.8-Sep-11 2:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.