I am using List<T> array to store all ID’s that I have read from my database file.
do lets say I have ID: 5, 8, 15
What I am trying to do is to check if user input matches one of the elements in this array.
How do I do this?
I have tried using Contains or Find, but I cannot manage to make it work.
Bit of the code which doesn’t seem to wok. It only shows Entry ID doesn't exist! only if I enter a letter (?).
List<int> fetchedEntries = new List<int>();
else if (!fetchedEntries.Contains(intNumber))
{
lblMessage.Text = "Entry ID doesn't exist!";
lblMessage.ForeColor = Color.IndianRed;
btnDeleteEntry.Enabled = false;
}
The easiest way is to use the
ContainsmethodYour Q said this isn’t working for you though. Could you give some more information? The above pattern should work just fine