I wrote this code:
class Program
{
static void Main(string[] args)
{
Test t = new Test();
int[] tal1 = { 3, 2, 3};
int[] tal2 = { 1, 2, 3};
Console.WriteLine(t.theSameInBoth(tal1,tal2));
}
}
class Test
{
public Boolean theSameInBoth(int[] a, int[] b)
{
bool check = false;
if (a.Length == b.Length)
{
for (int i = 0; i < a.Length; i++)
if (a[i].Equals(b[i]))
{
check = true;
return check;
}
}
return check;
}
}
So the deal here is. I need to send in two arrays with numbers in them. I then need to check the arrays through. If ALL the numbers in the array are identical. I need to set my check as true and return it. The only problem is. With the code i set here, where i sent an array with 3,2,3 and one with 1,2,3 it still return check as true.
I'm a newbie at this, so i hoped anyone in here could help me!