Use for each loop to output elements in an array : Array : Data Structure C# Examples


C# Examples » Data Structure » Array »

 

Use for each loop to output elements in an array









    
using  System;

class  MainClass
{
        public  static  void  Main()
        {
                string  s  =  "A  B  C  D  E";
                char[]  separators  =  {'  '};
                string[]  words  =  s.Split(separators);
                
                foreach  (object  obj  in  words)
                      Console.WriteLine("Word:  {0}",  obj);
        }
}
    
   
  
   



Output

Word: A
Word: B
Word: C
Word: D
Word: E


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Structure
» Array