Skip to content

Commit 689ac48

Browse files
author
John A. Addo
committed
Improve performance of the GetCountries Method
1 parent 527fb04 commit 689ac48

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

CountryHelper.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,8 @@ public List<Regions> GetRegionByCountryCode(string ShortCode)
6969
/// <summary>
7070
/// Gets the list of all countries in the worlld
7171
/// </summary>
72-
/// <returns>List<String> countries</returns>
73-
public List<String> GetCountries()
74-
{
75-
List<String> data = new List<string>();
76-
var countries = _Countries.Select(c => c.CountryName).ToList();
77-
foreach (var item in countries)
78-
{
79-
data.Add(item);
80-
}
81-
return countries;
82-
}
72+
/// <returns>IEnumerable<string> countries</returns>
73+
public IEnumerable<string> GetCountries() => _Countries.Select(c => c.CountryName);
8374

8475
}
8576
}

0 commit comments

Comments
 (0)