Use for each loop with array - CSharp Language Basics

CSharp examples for Language Basics:for each

Description

Use for each loop with array

Demo Code

using System;//from  ww w  .j a  va 2  s. co m
using static System.Console;
class Program
{
   static void Main(string[] args)
   {
      string[] names = { "A", "B", "C" };
      foreach (string name in names)
      {
         WriteLine($"{name} has {name.Length} characters.");
      }
   }
}

Result


Related Tutorials