Try below code:
List<string> objcountries = new List<string>();
CultureInfo[] objculture = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
foreach (CultureInfo getculture in objculture)
{
RegionInfo objregion = new RegionInfo(getculture.LCID);
if (!(objcountries.Contains(objregion.EnglishName)))
{
objcountries.Add(objregion.EnglishName);
}
}
objcountries.Sort();
int CountryId = 0;
foreach (string dtrow in objcountries)
{
CountryId += 1;
CountryDetails country = new CountryDetails();
country.CountryId = CountryId;
country.CountryName = dtrow;
details.Add(country);
}
Here I added one variable
CountryId and increment inside foreach loop. Then assigning it to CountryDetails Object.
Note: One suggestion instead of looping every time you can store the country values datasource like XML or Database.