Skip to content

Instantly share code, notes, and snippets.

@ZacharyPatten
Created August 3, 2022 20:15
Show Gist options
  • Save ZacharyPatten/91ba60c81257676c064cb6a13f32d3c2 to your computer and use it in GitHub Desktop.
Save ZacharyPatten/91ba60c81257676c064cb6a13f32d3c2 to your computer and use it in GitHub Desktop.
Dictionary<string, Event> events = new();
while (true)
{
Console.Clear();
Console.WriteLine("Menu...");
Console.WriteLine(" 1. Add an event");
Console.WriteLine(" 2. List all events");
Console.WriteLine(" 3. Exit");
Console.WriteLine();
switch (Console.ReadKey(true).Key)
{
case ConsoleKey.D1:
{
Console.WriteLine("Adding an event...");
Event e = new();
Console.Write("Enter event name: ");
e.Name = Console.ReadLine()!;
events.Add(e.Name, e);
Console.WriteLine("Event added. Press any key to continue...");
Console.ReadKey(true);
break;
}
case ConsoleKey.D2:
{
Console.WriteLine("Listing events...");
foreach (Event e in events.Values)
{
Console.WriteLine(e.Name);
}
Console.WriteLine("Press any key to continue...");
Console.ReadKey(true);
break;
}
case ConsoleKey.D3:
return;
}
}
class Event
{
public string Name { get; set; }
//public string Description { get; set; }
//public DateTime Start { get; set; }
//public DateTime End { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment