“does not contain a definition…and no extension method..” error

前端 未结 2 1474
予麋鹿
予麋鹿 2021-01-06 08:09

I have the following error message:

\'System.Collections.Generic.Dictionary\' does not
contain a definition for \'biff\' and no extensi         


        
2条回答
  •  一个人的身影
    2021-01-06 08:48

    The problem is this part: cart.biff. cart is of type Dictionary, not of type SpoofClass.

    I can only guess what you are trying to do, but the following code compiles:

    Dictionary cart = new Dictionary();
    int i=0;
    foreach (var item in dbContext.DBView)
    {
        cart.Add(i, new SpoofClass { biff = item.biff });
        ++i;
    }
    

提交回复
热议问题