0
How to get my loop to search the array for a single entry
I have a loop that's suppose to search an array for a value and display it if found. but unless the value is input multiple times it doesn't find it.
2 Réponses
+ 3
you don't need a loop
use one of static methods defined in the Array class:
Array.indexOf( YourArray , YourElement )
Array.LastIndexOf ( YourArray , YourElement )
Array.contains ( YourArray , YourElement )
there also another method
Array.Find ( YourArray , Predicate )
this searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire array.
see msdn for more information.
+ 1
thanks for the quick response.