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.

22nd Dec 2016, 6:52 PM
Jeffrey Damon Belcher
Jeffrey Damon Belcher - avatar
2 Antworten
+ 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.
22nd Dec 2016, 7:32 PM
HAL8999++;
HAL8999++; - avatar
+ 1
thanks for the quick response.
22nd Dec 2016, 7:36 PM
Jeffrey Damon Belcher
Jeffrey Damon Belcher - avatar