我有一個包含50類的屬性列表。我正在努力的是我試圖計算兩個屬性的不同值這個「計數」數字然後需要被添加到每個組的列表的末尾,例如: 例如:這裏是我班列表,通過屬性組,然後計算其他屬性的不同的值,並寫入數到列表屬性
public class ListType
{
public ListType()
{
}
public string ID { get; set; }
public string REGSID { get; set; }
public string county { get; set; }
public string act_loc { get; set; }
public string eviofnd { get; set; }
public string hmonth { get; set; }
public string hisnc { get; set; }
public string hinc { get; set; }
public string FIPS { get; set; }
public decimal back00 {get; set;}
public decimal ann00 { get; set; }
public int countDistinctID {get;set;}
}
我需要每個不同FIPS的不同IDS的計數,然後將不同的IDS是計數設置爲每個分組FIPS的countDistinctID財產。 ID FIPS其他列(仍需要該數據雖然)
4 1 ......
5 2 ....
4 1 ....
4 2 ....
1 3 .....
1 2 ....
2 1 .....
我需要的是這個... ID FIPS other columns co UNT 4 1 ...... 2個3行與FIPS = 1周,則2周不同的ID每FIPS的= 1
5 2 .... 3 3 rows w/FIPS=2 3 distinct IDS per FIps=2
4 1 .... 2
4 2 .... 3
1 3 ..... 1 1 row w/fips=3 1 distinct id perFIPS=3
1 2 .... 3
2 1 ..... 2
我已經解析在一個文件和我寫所有列到列表稱爲表data
我在計算不同的ID之後最終需要做的事情是將該計數值設置爲原始「數據」列表的countDistinctID,並對每個不同的FIPS和ID執行此操作。census.countDistinctID
這是非常接近我需要的,但我需要正確的計數到主要「數據」列表不知何故 – Jt2ouan
@ BS123這更新**數據**集合中的每個** ListType **對象 – Alireza