Reputation: 27
I tried following code to fill combobox with country names
private void PopulateCountryComboBox()
{
RegionInfo country = new RegionInfo(new CultureInfo("en-US", false).LCID);
List countryNames = new List();
foreach (CultureInfo cul in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
{
country = new RegionInfo(new CultureInfo(cul.Name, false).LCID);
countryNames.Add(country.DisplayName.ToString());
}
IEnumerable nameAdded = countryNames.OrderBy(names => names).Distinct();
foreach (string item in nameAdded)
{
cmbcountry.Items.Add(item);
}
}
I am getting following error
Using the generic type 'System.Collections.Generic.List' requires 1 type arguments
Upvotes: 3
Views: 2539
Reputation: 1988
Modify
RegionInfo country = new RegionInfo(new CultureInfo("en-US", false).LCID);
List countryNames = new List();
as
RegionInfo country = new RegionInfo(new CultureInfo("en-US", false).LCID);
List<string> countryNames = new List<string>();
this may solve your issue
Upvotes: 1
Reputation: 11840
List<T>
is a generic collection. You need to supply what type it's going to be a list of.
Try:
List<string> countryNames = new List<string>();
Upvotes: 4