How to print array with foreach in C#

1 Answer

0 votes
using System;

public class Test  {

   public static void Main()  {

        int[] arr = { 5, 7, 8, 2, 1, 3, 6 }; 

        foreach(int n in arr) 
            Console.Write(n + " "); 
   }
}



/*
run:

5 7 8 2 1 3 6 

*/

 



answered Dec 3, 2020 by avibootz

Related questions

1 answer 199 views
2 answers 264 views
1 answer 133 views
2 answers 269 views
1 answer 216 views
2 answers 299 views
1 answer 244 views
...