Use multiple yield statements : Yield : Data Structure C# Examples


C# Examples » Data Structure » Yield »

 

Use multiple yield statements









    
using  System;  
using  System.Collections;  
  
class  MyClass  {  
    public  IEnumerator  GetEnumerator()  {  
        yield  return  'A';  
        yield  return  'B';  
        yield  return  'C';  
        yield  return  'D';  
        yield  return  'E';  
    }  
}  
  
class  MainClass  {  
    public  static  void  Main()  {  
        MyClass  mc  =  new  MyClass();  
  
        foreach(char  ch  in  mc)  
            Console.Write(ch  +  "  ");  
  
        Console.WriteLine();  
    }  
}
    
   
  
   



Output

A B C D E


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Structure
» Yield