Click here to Skip to main content
15,913,055 members
Home / Discussions / C#
   

C#

 
AnswerRe: Typed Datasets vs. Custom Classes Pin
eggsovereasy2-Aug-06 9:59
eggsovereasy2-Aug-06 9:59 
QuestionDAL/BLL Best Practices Pin
econner2-Aug-06 8:08
econner2-Aug-06 8:08 
AnswerRe: DAL/BLL Best Practices [modified] Pin
eggsovereasy2-Aug-06 10:03
eggsovereasy2-Aug-06 10:03 
GeneralRe: DAL/BLL Best Practices Pin
econner2-Aug-06 10:12
econner2-Aug-06 10:12 
GeneralRe: DAL/BLL Best Practices Pin
eggsovereasy2-Aug-06 10:35
eggsovereasy2-Aug-06 10:35 
QuestionHow to assign text control's value to a numeric variable? Pin
Amol Ravatale2-Aug-06 7:54
Amol Ravatale2-Aug-06 7:54 
AnswerRe: How to assign text control's value to a numeric variable? Pin
Stefan Troschuetz2-Aug-06 8:34
Stefan Troschuetz2-Aug-06 8:34 
AnswerRe: How to assign text control's value to a numeric variable? Pin
engsrini2-Aug-06 8:35
engsrini2-Aug-06 8:35 
AnswerRe: How to assign text control's value to a numeric variable? Pin
BlackDice2-Aug-06 8:38
BlackDice2-Aug-06 8:38 
QuestionStrange Behavior Pin
Mehdi Mousavi2-Aug-06 5:43
Mehdi Mousavi2-Aug-06 5:43 
QuestionScreenshots Pin
Kovu172-Aug-06 5:08
Kovu172-Aug-06 5:08 
AnswerRe: Screenshots Pin
Judah Gabriel Himango2-Aug-06 5:24
sponsorJudah Gabriel Himango2-Aug-06 5:24 
GeneralRe: Screenshots Pin
Kovu172-Aug-06 23:22
Kovu172-Aug-06 23:22 
GeneralRe: Screenshots Pin
Judah Gabriel Himango3-Aug-06 4:21
sponsorJudah Gabriel Himango3-Aug-06 4:21 
Questionhow to create a color eyedroppper? Pin
relsirc2-Aug-06 4:36
relsirc2-Aug-06 4:36 
AnswerRe: how to create a color eyedroppper? Pin
Ennis Ray Lynch, Jr.2-Aug-06 4:42
Ennis Ray Lynch, Jr.2-Aug-06 4:42 
Questionhow to remove duplicate characters from a text file [modified] Pin
vp152-Aug-06 4:35
vp152-Aug-06 4:35 
AnswerRe: how to remove duplicate characters from a text file Pin
Ennis Ray Lynch, Jr.2-Aug-06 4:44
Ennis Ray Lynch, Jr.2-Aug-06 4:44 
QuestionClass doesn't support Automation [modified] Pin
Lupson2-Aug-06 4:21
Lupson2-Aug-06 4:21 
QuestionHow to set zoom in WebBrowser? Pin
Dima Filipiuk2-Aug-06 3:46
Dima Filipiuk2-Aug-06 3:46 
QuestionCompare values with List Pin
abnorm2-Aug-06 3:30
abnorm2-Aug-06 3:30 
Hi,

I have two generic Lists of data and I want to compare the values.

Fill the mappinglist we want to compare the sourcelist with
            <br />
List<MappingItem> MappingList = new List<MappingItem>();<br />
MappingList.Add(new MappingItem("11", "1"));<br />
MappingList.Add(new MappingItem("22", "2"));<br />
//leave out for test  MappingList.Add(new MappingItem("33", "3"));<br />
MappingList.Add(new MappingItem("44", "4"));<br />
MappingList.Add(new MappingItem("55", "5"));<br />


Fill the Sourcelist we want to deal with
<br />
List<SourceItem> SourceList = new List<SourceItem>();<br />
SourceList.Add(new SourceItem("11", "Value one"));<br />
SourceList.Add(new SourceItem("22", "Value two"));<br />
SourceList.Add(new SourceItem("33", "Value three"));<br />
SourceList.Add(new SourceItem("44", "Value four"));<br />
SourceList.Add(new SourceItem("55", "Value five"));<br />


Make a instance of the DestinationList and the Itemobject
<br />
List<DestinationItem> DestinationList = new List<DestinationItem>(); <br />
DestinationItem destItem;<br />


Here is the problem Im stuck with. How shall I compare the values between these lists in a high performance way och with nice methods?


This is a uncomplete way, maybe u have a better method but I hope you understand what Im looking for!?!

<br />
<br />
foreach (MappingItem mappItem in MappingList.FindAll(new Predicate<MappingItem>(???)))<br />
{<br />
  destItem = new DestinationItem(mappItem.DestId,"?SourceItem.Value?");<br />
  DestinationList.Add(destItem);<br />
}<br />
<br />


Write the output
<br />
            DestinationList.ForEach(delegate(DestinationItem d)<br />
            { Console.WriteLine("DestId: {0}, Value: {1}", d.DestId, d.Value); });<br />


Output result:
DestId: 1, DestValue: value one
DestId: 2, DestValue: value two
DestId: 4, DestValue: value four
DestId: 5, DestValue: value five


I hope I make my self clearSmile | :)
//Albin
AnswerRe: Compare values with List [modified] Pin
Wjousts2-Aug-06 3:48
Wjousts2-Aug-06 3:48 
AnswerRe: Compare values with List Pin
Ingo2-Aug-06 3:48
Ingo2-Aug-06 3:48 
GeneralRe: Compare values with List Pin
Wjousts2-Aug-06 4:01
Wjousts2-Aug-06 4:01 
GeneralRe: Compare values with List Pin
abnorm2-Aug-06 4:13
abnorm2-Aug-06 4:13 

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.