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 194 views
194 views asked Nov 25, 2020 by avibootz
1 answer 199 views
1 answer 183 views
1 answer 195 views
2 answers 257 views
2 answers 264 views
1 answer 201 views
...