Note that there are some explanatory texts on larger screens.

plurals
  1. POComparison of items in two ArrayLists and return differences
    primarykey
    data
    text
    <p>I'm currently writing a simple app to compare two lists and return differences if any are found.</p> <p>Note - [int] imaginary index for the purpose of this explanation</p> <pre><code>//---------------Prep---------------------------- ArrayList list1 = new ArrayList(); ArrayList storage = new ArrayList(); ArrayList list2 = new ArrayList(); string path = Application.ExecutablePath; string root = Path.GetDirectoryName(path); //---------------END Prep------------------------ //---------------Load content into list1------------------------ StreamReader objReader = new StreamReader(root + "/healthy.txt"); string sLine = ""; while (sLine != null) { sLine = objReader.ReadLine(); if (sLine != null) list1.Add(sLine); } objReader.Close(); //---------------END Load content into list1------------------------ //---------------Load content into list2------------------------ string[] files = Directory.GetFiles(root, "*.txt", SearchOption.AllDirectories); foreach (string file in files) { storage.Add(file.ToString()); } foreach (string sOutput2 in storage) { list2.Add(GetMD5HashFromFile(sOutput2)); } //---------------END Load content into list2------------------------ </code></pre> <p>I tried everything, but it seems that I cannot crack this.. How do I ''loop'' through both lists and compare each item side by side in order then return the one's in list two that do not match the control list(list one)?</p> <p>Logically the program would return ''More work'' as the wrong entry, because both "music" and "more work" are in the third row of their respective lists, they get checked and do not match. List 1 is control, so list 2's entry gets recorded as the odd one out.</p> <p>Now I have tried it right and left, but I cannot make it happen.. Anyone out there who would be willing to shed some light on this or perhaps even guide me through to the right answer?</p> <p>Many thanks</p> <p>EDIT: Added my code for both arrayLists, im only missing the comparison function...</p> <p>No particular reason for using ArrayList, any suggestions that would make this process easier are very welcome.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload