简体   繁体   English

错误 CS1929“int[]”不包含“Contains”的定义

[英]Error CS1929 'int[]' does not contain a definition for 'Contains'

Error CS1929 'int[]' does not contain a definition for 'Contains' and the best extension method overload 'Queryable.Contains(IQueryable, int?)' requires a receiver of type 'IQueryable错误 CS1929 'int[]' 不包含 'Contains' 的定义,并且最好的扩展方法重载 'Queryable.Contains(IQueryable, int?)' 需要一个类型为 'IQueryable 的接收器

once i try to run the code this error comes out , i dont know how to fix it.一旦我尝试运行代码,就会出现此错误,我不知道如何修复它。 this is the code这是代码

public void SendModelPallet(string IDs, StorageContext db)
        {
           int[] ids = ViewModelsUtils.processIDs(IDs);
           PalletBoxes = db.ExternStoragePlaces.Where(c => ids.Contains(c.PalletPlaceID)).ToList();
            this.db = db;
        }

Thanks in advance提前致谢

Just a guess here, but I remember having had problems with nulll coalescing in some Linq to SQL queries.这里只是一个猜测,但我记得在某些 Linq to SQL 查询中遇到 nulll 合并问题。 I recommend you to try to declare your ids array as this :我建议您尝试将您的 ids 数组声明为:

int?[] ids = ViewModelsUtils.processIDs(IDs);

(use int?[] instead of int[] so this will match the type of your field) (使用int?[]而不是int[]这样这将匹配您的字段类型)

Not sure about this, first because it doesn't seem to match the compilation error message, and secondly because I don't have a way to test this for the moment.对此不确定,首先是因为它似乎与编译错误消息不匹配,其次是因为我暂时没有办法对此进行测试。

Had the same issue while using Delegates[] and used to get the CS1929: 'Delegate?[]' does not contain a definition for 'Contains'在使用 Delegates[] 并用于获取CS1929: 'Delegate?[]' does not contain a definition for 'Contains'同样的问题CS1929: 'Delegate?[]' does not contain a definition for 'Contains'

Just included the System.Linq namespace and works fine now.刚刚包含System.Linq命名空间,现在工作正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C# 错误:CS1929 不包含“包含”的定义 - C# error: CS1929 does not contain a definition for 'Contains' CS1929“IHttpClientFactory”不包含“GetFromJsonAsync”的定义 - CS1929 'IHttpClientFactory' does not contain a definition for 'GetFromJsonAsync' CS1929 C#“RfcParameterClass”不包含“Cast”的定义 - CS1929 C# 'RfcParameterClass' does not contain a definition for 'Cast' CS1929 - 列表<t>不包含 Where() 的实现(使用 System.Linq)</t> - CS1929 - List<T> does not contain an implementation of Where() (using System.Linq) CS1929 - 尝试读取文件,并跳到包含特定字符串的行并返回该行的内容 - CS1929 - Trying to read a file, and skip to the line that contains a certain string and return that line's content 错误CS1929,当我尝试在列表视图中创建搜索栏时,有人可以检查我的代码是否有错误? - Error CS1929 when i try to make a searchbar in a listview can someone check my code for errors? &#39;int []&#39;不包含&#39;Contains&#39;的定义 - 'int[]' does not contain a definition for 'Contains' Linq-to-sql 错误:“int[]”不包含“包含”的定义 - Linq-to-sql error: 'int[]' does not contain a definition for 'Contains' 不包含“包含”的定义 - Does not contain definition for 'Contains' C#错误CS1061:输入`System.Collections.Generic.List <int> &#39;不包含&#39;Length&#39;的定义 - C# error CS1061: Type `System.Collections.Generic.List<int>' does not contain a definition for `Length'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM