Potrebno je upotrebom LINQ jezika obaviti prikaz zemalja sortiranih po broju stanovnika.Znači, od najvećeg do najmanjeg broja. Ovako izgleda kod koji sam napisala,krajnji rezultat izbacije samo . Country: ,Population: ... Bez podataka za drzavu i populaciju... VS mi ne pokazuje gresku u kodu, a ja sam nešto promašila u pisanju, a ne mogu da skontam šta.. Može li pomoć??
Evo kod:
namespace CountryApp
{
class Country
{
public string Name { get; set; }
public int Population { get; set; }
public Country ( string name, int population )
{
this.Name = name;
this.Population = population;
}
}
class Program
{
public static void Main ()
{
Country[] countryCollection = { new Country("Afganistan", 34656032),
new Country("Austria", 8857960),
new Country("Brazil", 210147125),
new Country("Denmark", 5789957),
new Country("Russia", 144526636),
new Country("China", 1403500365),
new Country("Turkey", 8010525),
new Country("Serbia", 7001444),
new Country("Iraq", 37202572),
new Country("San Marino", 33344)
};
var countryInfo = from country in countryCollection
orderby country.Population descending, country.Name
select country;
Console.WriteLine("Countrys sorted by Population Number:");
foreach (Country country in countryCollection)
Console.WriteLine("Country : , Population : ");
Console.ReadKey();
}
}
}