我有以下錯誤信息:「不包含定義...並沒有擴展方法。」錯誤
'System.Collections.Generic.Dictionary<int,SpoofClass>' does not
contain a definition for 'biff' and no extension method 'biff'
accepting a first argument of type
'System.Collections.Generic.Dictionary<int,SpoofClass>' could be found
(are you missing a using directive or an assembly reference?)
我SO檢查這一點,我發現this問題這似乎也有類似的(如果不相同)問題,我有。但是,我嘗試了接受答案中提供的解決方案,但仍然沒有提出任何解決方案。這就像我錯過了一個使用聲明,但我幾乎積極,我有我需要的所有使用。
下面是一些正在生產中的錯誤代碼:
using locationOfSpoofClass;
...
Dictionary<int, SpoofClass> cart = new Dictionary<int, SpoofClass>();
foreach (var item in dbContext.DBView)
{
cart.biff = item.biff;
...
}
SpoofClass文件:
namespace locationOfSpoofClass
{
public class SpoofClass
{
public int biff { get; set; }
...
}
}
很抱歉,如果我的變量和諸如此類的東西重命名是混亂的。如果它不可讀,或者太難遵守,或者其他信息與解決方案有關,請告訴我。謝謝!
該代碼將不會編譯爲車[鍵]的類型SpoofClass的而item.biff是int。 –
@Ben:我剛剛修好了 –
@你說得對。感謝編輯Daniel –