我有以下错误信息:“不包含定义...并没有扩展方法。”错误
'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 –