2014-01-14 24 views
1

我收到錯誤數類型是不兼容與運營商

數類型是不兼容與運營商

在標題

試圖比較兩個「真實」數據類型時。

任何人都可以幫我解決問題嗎?

public void clicked() 
{ 
    real localAnnualUsage = itemSetup_DS.AnnualUsage(); 
    real localSalesPrice  = itemSetup.StockPrice; 
    real localCost   = itemSetup.StockCost; 
    real localstockInventAvg = itemSetup.StockInventAvg; 

    real localTurnAndEarn; 
    real localAnnualGP; 
    real localAvgInvCost; 
    ; 

    localAvgInvCost = itemSetup.StockInventAvg; 

    if (localStockInventAvg != itemSetup_StockInventAvg) 
    { 
     localAvgInvCost = itemSetup_StockInventAvg; 
    } 

    //... 
} 

錯誤發生在條件的行上。

回答

5

最有可能你的itemSetup_StockInventAvg變量是真實的控制,不是一個真實的。

嘗試使用:

if (localStockInventAvg != itemSetup_StockInventAvg.realValue()) 

或更好(因爲控制結果存儲在itemSetup.StockInventAvg):

if (localStockInventAvg != itemSetup.StockInventAvg) 

更新:這是沒有意義的,因爲localStockInventAvg設置爲itemSetup.StockInventAvg前行。