Created
September 23, 2019 19:38
-
-
Save mhkoca/ee8d869db105815b0f02cd38c641e708 to your computer and use it in GitHub Desktop.
This file contains hidden or 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.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