I've got two string arrays. I want to select one element from the first array and compare to each element of the second array. If element from first array exist in elements of second array i whant to write for example ("Element exist") or something like this.
This should be possible to do with two for loops ?
EDIT
Ok i finaly achived what i wanted usign this code:
string[] ArrayA = { "dog", "cat", "test", "ultra", "czkaka", "laka","kate" };
string[] ArrayB = { "what", "car", "test", "laka","laska","kate" };
bool foundSwith = false;
for (int i = 0; i < ArrayA.Length; i++)
{
for (int j = 0; j < ArrayB.Length; j++)
{
if (ArrayA[i].Equals(ArrayB[j]))
{
foundSwith = true;
Console.WriteLine("arrayA element: " + ArrayA[i] + " was FOUND in arrayB");
}
}
if (foundSwith == false)
{
Console.WriteLine("arrayA element: " + ArrayA[i] + " was NOT found in arrayB");
}
foundSwith = false;
}
I hope this will help others who will want to compare two arrays ;). its all about this foundSwitch. Thx for help once again.
else if (s1 != s2)with onlyelse... and it will work fine... what is the problem then?