Skip to content

Instantly share code, notes, and snippets.

@mhkoca
Created September 23, 2019 19:38
Show Gist options
  • Select an option

  • Save mhkoca/ee8d869db105815b0f02cd38c641e708 to your computer and use it in GitHub Desktop.

Select an option

Save mhkoca/ee8d869db105815b0f02cd38c641e708 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
namespace DictionaryTraining
{
public class Program
{
static Dictionary<ReportType, Action> dictReports = new Dictionary<ReportType, Action>();
static void Main(string[] args)
{
Reporter reporter = new Reporter();
dictReports.Add(ReportType.Daily, new Action(reporter.GetDailyReport));
dictReports.Add(ReportType.Weekly, new Action(reporter.GetWeeklyReport));
dictReports.Add(ReportType.Monthly, new Action(reporter.GetMonthlyReport));
dictReports.Add(ReportType.Annual, new Action(reporter.GetAnnualReport));
dictReports[ReportType.Weekly]();
Console.ReadLine();
}
}
public class Reporter
{
public void GetDailyReport()
{
Console.WriteLine("Daily report is preparing...");
}
public void GetWeeklyReport()
{
Console.WriteLine("Weekly report is preparing...");
}
public void GetMonthlyReport()
{
Console.WriteLine("Monthly report is preparing...");
}
public void GetAnnualReport()
{
Console.WriteLine("Annual report is preparing...");
}
}
enum ReportType
{
Daily,
Weekly,
Monthly,
Annual
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment