2014-07-08 33 views
-2

有人能解釋一下這裏發生了什麼嗎?非零雙?除以int 100返回null

var percentage = Percentages[fund]; // percentage is a double? equal to 44.8 
var translated = percentage/100; 

對於我的生活,我不明白爲什麼這導致在translated == null

這是怎麼發生的?

編輯:

以下是完整的問題:

double? thisFundPercentage = NewAllocationPercentages.Percentages[fund]/ 100; // .448 
double? total = CurrentNotionals.Total(); // -200000 
double? newValue = total * (thisFundPercentage); // newValue == null 
+7

請顯示顯示問題的最短完整樣本。顯然'雙? v = 44.8; var r = v/100;'不顯示行爲。 –

+0

我很確定其中的一些其實是錯誤的。百分比[基金]是不是兩倍?等於44.8或翻譯不爲空。 – Stilgar

+2

我會嘗試拿出你的變量和替換雙打,並可能幫助你找到一個問題 –

回答

1

Percentages[fund]必須null那裏。這是從/100分部獲得null的唯一途徑。