無法從雙轉換爲int,我的計劃是試圖減去從它的列表,並將結果添加到一個新的列表,但出於某種原因即時得到這個錯誤:C#「不能隱式地從雙轉換爲int」
List<double> test = new List<double>();
List<double> theOneList = new List<double>();
theOneList = wqList.Concat(rList).Concat(eList).ToList();
theOneList.Add(0);
theOneList.OrderByDescending(z => z).ToList();
for (double i = 0; i < 5; i++)
{
test.Add(theOneList[i + 2.0] - theOneList[i + 3.0]);
Console.WriteLine(test[i]);
}
摘要:當我打印出來的清單即時得到INT的,而不是雙倍的,我已經失去了這個名單上的精度,因爲「詮釋」聲明
不能使用雙值作爲一個表的或數組的索引。有沒有你不使用整數的原因? – Jules
哦,jeez,也許是因爲我想把值保持爲double?通過使用(int)即時獲得我的答案作爲整體數字,從而失去了精度 – AdanChristo
您的列表的通用類型和您的索引方式根本沒有關係。你可以有一個字符串列表或者double列表等等,但是你總是需要用一個int來索引它......對索引列表的第1.5個元素沒有任何意義:) –