-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (48 loc) · 1.51 KB
/
Program.cs
File metadata and controls
57 lines (48 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// See https://aka.ms/new-console-template for more information
PrintSeparator("All Countries");
var countries = CountryProvider.GetAllCountries();
foreach (var country in countries)
{
Console.WriteLine($"Name: {country.Name,-20} | Capital: {country.Capital}");
}
Console.WriteLine();
PrintSeparator("Afghanistan");
try
{
var afghanistan = CountryProvider.GetCountry(CountryIdentifier.Afghanistan);
Console.WriteLine($"Official Name: {afghanistan.OfficialName}");
Console.WriteLine($"Capital: {afghanistan.Capital}");
}
catch (CountryNotFoundException ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
PrintSeparator("Selected Countries");
var indentifiers = new List<CountryIdentifier>
{
CountryIdentifier.Afghanistan,
CountryIdentifier.Armenia,
CountryIdentifier.Niger,
CountryIdentifier.Nigeria,
CountryIdentifier.Brazil
};
var selectedCountries = CountryProvider.GetCountries(indentifiers);
foreach (var country in selectedCountries)
{
Console.WriteLine($"Name: {country.Name,-20} | Capital: {country.Capital}");
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
/// <summary>
/// Prints a formatted section separator in the console.
/// </summary>
/// <param name="title">The title to display in the separator.</param>
static void PrintSeparator(string title)
{
Console.WriteLine(new string('-', 30));
Console.WriteLine($"--- {title} ---");
Console.WriteLine(new string('-', 30));
Console.WriteLine();
}