When I run this syntax my messagebox tells me that the value exists in array 2 AND I get a message stating the value does not exist.
What is causing both messages to show? And how do I re-write to remedy this?
string[] Arr1 = new string[] { "Game1", "Game2", "Game3" };
string[] Arr2 = new string[] { "Vid1", "Vid2", "Vid3" };
string[] Arr3 = new string[] { "Con1", "Con2", "Con3" };
string sVal = "Vid1";
if (Arr1.Any(x => x == sVal))
{
MessageBox.Show("Value Exists in Array 1");
}
if (Arr2.Any(x => x == sVal))
{
MessageBox.Show("Value Exists in Array 2");
}
if (Arr3.Any(x => x == sVal))
{
MessageBox.Show("Value Exists in Array 3");
}
else
{
MessageBox.Show("Value Does Not Exists in Any Array");
}
Aucun commentaire:
Enregistrer un commentaire