Use a foreach loop through an int array : Int array : Data Type C# Examples


C# Examples » Data Type » Int array »

 

Use a foreach loop through an int array









    
class  MainClass
{

    public  static  void  Main()
    {

        int  []  myValues  =  {2,  4,  3,  5,  1};
        foreach  (int  counter  in  myValues)
        {
            System.Console.WriteLine("counter  =  "  +  counter);
        }

    }

}
    
   
  
   



Output

counter = 2
counter = 4
counter = 3
counter = 5
counter = 1


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Int array