[2005] Comparing string arrays
I can't get my head around this. Can anyone help?
Given two string arrays, I need to create a third array/string which contains the additions...
e.g.
ARRAY1
Bob
Jane
Paul
ARRAY2
Bob
Mary
Jane
Paul
John
I need a routine that will tell me that Mary and John have been added - e.g. a string result of "Mary,John"
Also, it's possible that some items originally in ARRAY1 might not be present in ARRAY2.
e.g.
ARRAY1
Bob
Jane
Paul
ARRAY2
Mary
Jane
John
Again, all I want to know is that Mary and John were added to the array - I don't need to know that Bob and Paul were removed.
Can anyone help?
Re: [2005] Comparing string arrays
You need to loop through the elements of array 2 and call Array.IndexOf to see if that element is in array 1. If Array.IndexOf returns -1 then the value is not in the array.