Skip to content

Instantly share code, notes, and snippets.

@JohnBaek
Created June 28, 2017 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohnBaek/100566bbe346dc0c1d31f9d3c4da40b6 to your computer and use it in GitHub Desktop.
Save JohnBaek/100566bbe346dc0c1d31f9d3c4da40b6 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Threading;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
List<ISayHello> speakers = new List<ISayHello>();
ISayHello normalSpeaker = new NormalSpeaker();
ISayHello crazySpeaker = new CrazySpeaker();
speakers.Add(normalSpeaker);
speakers.Add(crazySpeaker);
speakers.ForEach(s => s.SayOutLoud());
Console.ReadKey();
}
}
public class NormalSpeaker : ISayHello
{
public void SayOutLoud()
{
Console.WriteLine("Normarl Speaker");
}
}
public class CrazySpeaker : ISayHello
{
public void SayOutLoud()
{
Console.WriteLine("Fuck!");
}
}
public interface ISayHello
{
void SayOutLoud();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment