C# program to iterate over a string array with for loop



Create a string array −

string[] str = new string[] {    "Videos",    "Tutorials",    "Tools",    "InterviewQA" };

Loop until the length of the array −

for (int i = 0; i < str.Length; i++) {    string res = str[i];    Console.WriteLine(res); }

Here is the complete code −

Example

 Live Demo

using System; public class Demo {    public static void Main() {       string[] str = new string[] {          "Videos",          "Tutorials",          "Tools",          "InterviewQA"       };           Console.WriteLine("String Array...");       for (int i = 0; i < str.Length; i++) {          string res = str[i];          Console.WriteLine(res);       }    } }

Output

String Array... Videos Tutorials Tools InterviewQA
Updated on: 2020-06-22T13:52:06+05:30

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements