我使用下面的類計算平均每組
class Country
{
int CountryID {get; set;}
List<City> city {get; set;}
}
class City
{
int CountryID {get; set; }
string city {get; set;}
int sqkm {get; set;}
}
這裏是國家和城市
國家
美國
英國
加拿大
市
CityC
CityF
CityA
CityB
CityG
CityD
CityE
我使用
List<Country> countries = new List<Country> { new Country() { CountryID = "US", city = new List<City> { new City() {CountryID = "US", City ="CityF", sqkm = 2803 }, and so on
問題1填充:我想使用LINQ發現平均平方的每個國家土地
EG公里。
加拿大 - 2459
英國 - 3243
美國 - 3564
非常感謝..它工作...你能幫助我在這個線程上http://stackoverflow.com/questions/2872617/ordering-group-of-records使用表達式語法 – Gokul 2010-05-20 11:27:27
你用c.city 。平均在這裏..如果使用類似的查詢,我想訪問c.city.sqkm? – Gokul 2010-05-20 11:34:16