Want to see a simple example on how to search an array in c# ? See the following lines of code.

using System;

class MainClass {
  public static void Main() {
    int[] myArray = new int[25];
    int test;
    bool search= false;

    for(int i = 0; i < 25; i++)
      myArray [i] = i;

    test= 17;

    foreach(int m in myArray ) {
      if(m == test) {
        search= true;

      Console.WriteLine("Yahooo! Found it in Array!!!");

Output-“Yahooo! Found it in Array!!!”



Leave a Reply

Your email address will not be published. Required fields are marked *




Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.