Created
April 27, 2012 09:05
-
-
Save tnngo2/2507655 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace Theory8 | |
{ | |
class NamedIterators | |
{ | |
private string[] cars = {"Ferrari", "Mercedes", "BMW", "Toyota", "Nissan"}; | |
public IEnumerable GetCarNames() | |
{ | |
for (int i = 0; i < cars.Length; i++) | |
{ | |
yield return cars[i]; | |
} | |
} | |
static void Main(string[] args) | |
{ | |
NamedIterators objIterator = new NamedIterators(); | |
foreach (string car in objIterator.GetCarNames()) | |
{ | |
Console.WriteLine(car); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment