How to use foreach loop with array in C#

1 Answer

0 votes
using System;
  
class Program
{
    static void Main() {
        string[] arr = { "c#", "c", "c++", "java", "rust" };
         
        foreach (string s in arr) {
            Console.WriteLine(s);
        }
    }
}
  
  
  
  
/*
run:
  
c#
c
c++
java
rust
  
*/
 

 



answered Mar 6, 2023 by avibootz
edited Aug 25, 2023 by avibootz

Related questions

2 answers 187 views
187 views asked Nov 25, 2020 by avibootz
1 answer 189 views
1 answer 173 views
1 answer 185 views
2 answers 250 views
2 answers 257 views
1 answer 192 views
...