Fake a Repository Collection example in C#.
using System.Collections.Generic;
namespace EmailNotificationSender
{
class Customer
{
public string FirstName { get; set; }
public string SecondName { get; set; }
public string EmailAddress { get; set; }
}
class CustomerRepository
{
public IEnumerable<Customer> GetAll()
{
yield return new Customer
{
FirstName = "Sarah",
SecondName = "Smith",
EmailAddress = "ssmith@dontcodetired.com"
};
yield return new Customer
{
FirstName = "Gentry",
SecondName = "Jones",
EmailAddress = "jonesyg@dontcodetired.net"
};
yield return new Customer
{
FirstName = "Arnold",
SecondName = "Day",
EmailAddress = "daytimedontcodetired.net"
};
}
}
class Program
{
static void Main(string[] args)
{
var repository = new CustomerRepository();
var customers = repository.GetAll();
foreach (var customer in customers)
{
// ... do something with each customer
}
Console.ReadLine();
}
}
}