CSharp examples for System:Array Search
Determine if the array contains the specified number.
// Licensed under the Apache License, Version 2.0 (the "License"); using System.Collections.Generic; using System;/*from ww w.j av a2 s .c o m*/ public class Main{ /// <summary> /// Determine if the array contains the specified number. /// </summary> /// <param name="array">The array to search.</param> /// <param name="target">The number being searched for.</param> /// <returns>True, if the number was found.</returns> public static bool Contains(int[] array, int target) { for (int i = 0; i < array.Length; i++) { if (array[i] == target) { return true; } } return false; } }