1-
2- using CountryData . Standard ;
1+ using CountryData . Standard ;
32
4- /// <summary>
5- /// Main program class for demonstrating the use of the CountryData library.
6- /// </summary>
7- class Program
3+ namespace CountryData . Sample . CountryConsoleProject
84{
95 /// <summary>
10- /// Static instance of CountryHelper used throughout the program .
6+ /// Main program class for demonstrating the use of the CountryData library .
117 /// </summary>
12- private static readonly CountryHelper _helper = new CountryHelper ( ) ;
13-
14- /// <summary>
15- /// Entry point of the program.
16- /// </summary>
17- public static void Main ( )
18- {
19- GetCountries ( ) ;
20- GetCountryByCode ( "US" ) ;
21- GetCountryData ( ) ;
22- GetRegionsByCountryCode ( "US" ) ;
23- GetCountryFlag ( "US" ) ;
24- GetPhoneCodeByCountryShortCode ( "AF" ) ;
25- GetCountryByPhoneCode ( "+233" ) ;
26-
27-
28- }
29-
30- /// <summary>
31- /// Retrieves a list of all countries and prints them to the console.
32- /// </summary>
33- static void GetCountries ( )
8+ public static class Program
349 {
35- var countries = _helper . GetCountries ( ) ;
36- Console . WriteLine ( "Countries:" ) ;
37- foreach ( var country in countries )
10+ /// <summary>
11+ /// Static instance of CountryHelper used throughout the program.
12+ /// </summary>
13+ private static readonly CountryHelper _helper = new CountryHelper ( ) ;
14+
15+ /// <summary>
16+ /// Entry point of the program.
17+ /// </summary>
18+ public static void Main ( )
3819 {
39- Console . WriteLine ( country ) ;
20+ GetCountries ( ) ;
21+ GetCountryByCode ( "US" ) ;
22+ GetCountryData ( ) ;
23+ GetRegionsByCountryCode ( "US" ) ;
24+ GetCountryFlag ( "US" ) ;
25+ GetPhoneCodeByCountryShortCode ( "AF" ) ;
26+ GetCountryByPhoneCode ( "+233" ) ;
4027 }
41- }
42-
43- /// <summary>
44- /// Retrieves the data for a given country code and prints it to the console.
45- /// </summary>
46- /// <param name="countryCode">The ISO country code.</param>
47- static void GetCountryByCode ( string countryCode )
48- {
49- var country = _helper . GetCountryByCode ( countryCode ) ;
50- Console . WriteLine ( $ "Country data for { countryCode } :") ;
51- Console . WriteLine ( country . CountryName ) ;
52- }
5328
54- /// <summary>
55- /// Retrieves comprehensive data for all countries and prints it to the console.
56- /// </summary>
57- static void GetCountryData ( )
58- {
59- var countryData = _helper . GetCountryData ( ) ;
60- Console . WriteLine ( "Country data:" ) ;
61- foreach ( var data in countryData )
29+ /// <summary>
30+ /// Retrieves a list of all countries and prints them to the console.
31+ /// </summary>
32+ static void GetCountries ( )
6233 {
63- Console . WriteLine ( data . CountryName ) ;
34+ var countries = _helper . GetCountries ( ) ;
35+ Console . WriteLine ( "Countries:" ) ;
36+ foreach ( var country in countries )
37+ {
38+ Console . WriteLine ( country ) ;
39+ }
6440 }
65- }
6641
67- /// <summary>
68- /// Retrieves the regions for a given country code and prints them to the console.
69- /// </summary>
70- /// <param name="countryCode">The ISO country code.</param>
71- static void GetRegionsByCountryCode ( string countryCode )
72- {
73- var regions = _helper . GetRegionByCountryCode ( countryCode ) ;
74- Console . WriteLine ( $ "Regions for { countryCode } :") ;
75- foreach ( var region in regions )
42+ /// <summary>
43+ /// Retrieves the data for a given country code and prints it to the console.
44+ /// </summary>
45+ /// <param name="countryCode">The ISO country code.</param>
46+ static void GetCountryByCode ( string countryCode )
7647 {
77- Console . WriteLine ( region . Name ) ;
48+ var country = _helper . GetCountryByCode ( countryCode ) ;
49+ Console . WriteLine ( $ "Country data for { countryCode } :") ;
50+ Console . WriteLine ( country . CountryName ) ;
7851 }
79- }
8052
81- /// <summary>
82- /// Retrieves the emoji flag for a given country short code and prints it to the console.
83- /// </summary>
84- /// <param name="shortCode">The country short code.</param>
85- static void GetCountryFlag ( string shortCode )
86- {
87- var flag = _helper . GetCountryEmojiFlag ( shortCode ) ;
88- Console . WriteLine ( $ "Flag for { shortCode } :") ;
89- Console . WriteLine ( flag ) ;
90- }
53+ /// <summary>
54+ /// Retrieves comprehensive data for all countries and prints it to the console.
55+ /// </summary>
56+ static void GetCountryData ( )
57+ {
58+ var countryData = _helper . GetCountryData ( ) ;
59+ Console . WriteLine ( "Country data:" ) ;
60+ foreach ( var data in countryData )
61+ {
62+ Console . WriteLine ( data . CountryName ) ;
63+ }
64+ }
9165
66+ /// <summary>
67+ /// Retrieves the regions for a given country code and prints them to the console.
68+ /// </summary>
69+ /// <param name="countryCode">The ISO country code.</param>
70+ static void GetRegionsByCountryCode ( string countryCode )
71+ {
72+ var regions = _helper . GetRegionByCountryCode ( countryCode ) ;
73+ Console . WriteLine ( $ "Regions for { countryCode } :") ;
74+ foreach ( var region in regions )
75+ {
76+ Console . WriteLine ( region . Name ) ;
77+ }
78+ }
9279
80+ /// <summary>
81+ /// Retrieves the emoji flag for a given country short code and prints it to the console.
82+ /// </summary>
83+ /// <param name="shortCode">The country short code.</param>
84+ static void GetCountryFlag ( string shortCode )
85+ {
86+ var flag = _helper . GetCountryEmojiFlag ( shortCode ) ;
87+ Console . WriteLine ( $ "Flag for { shortCode } :") ;
88+ Console . WriteLine ( flag ) ;
89+ }
9390
94- /// <summary>
95- /// Retrieves the phone code for a given country short code and prints it to the console.
96- /// </summary>
97- /// <param name="shortCode">The country short code.</param>
98- static void GetPhoneCodeByCountryShortCode ( string shortCode )
99- {
100- var phoneCode = _helper . GetPhoneCodeByCountryShortCode ( shortCode ) ;
101- Console . WriteLine ( $ "Phone code for { shortCode } :") ;
102- Console . WriteLine ( phoneCode ) ;
103- }
91+ /// <summary>
92+ /// Retrieves the phone code for a given country short code and prints it to the console.
93+ /// </summary>
94+ /// <param name="shortCode">The country short code.</param>
95+ static void GetPhoneCodeByCountryShortCode ( string shortCode )
96+ {
97+ var phoneCode = _helper . GetPhoneCodeByCountryShortCode ( shortCode ) ;
98+ Console . WriteLine ( $ "Phone code for { shortCode } :") ;
99+ Console . WriteLine ( phoneCode ) ;
100+ }
104101
105- /// <summary>
106- /// Retrieves the country name for a given phone code and prints it to the console.
107- /// </summary>
108- /// <param name="phoneCode">The phone code.</param>
109- static void GetCountryByPhoneCode ( string phoneCode )
110- {
111- var countries = _helper . GetCountriesByPhoneCode ( phoneCode ) ;
112- Console . WriteLine ( $ "Countries for phone code { phoneCode } :") ;
113- foreach ( var country in countries )
102+ /// <summary>
103+ /// Retrieves the country name for a given phone code and prints it to the console.
104+ /// </summary>
105+ /// <param name="phoneCode">The phone code.</param>
106+ static void GetCountryByPhoneCode ( string phoneCode )
114107 {
115- Console . WriteLine ( country . CountryName ) ;
108+ var countries = _helper . GetCountriesByPhoneCode ( phoneCode ) ;
109+ Console . WriteLine ( $ "Countries for phone code { phoneCode } :") ;
110+ foreach ( var country in countries )
111+ {
112+ Console . WriteLine ( country . CountryName ) ;
113+ }
116114 }
117115 }
118-
119-
120-
121- }
116+ }
0 commit comments