如何在情节中的字符串列表中搜索substring
有这样的字符串列表
"Users": [
"usrName|Fullname|False|0|False|False",
"usrName|Fullname|False|0|False|False",
"usrName|Fullname|False|0|False|False",
"usrName|Fullname|False|0|False|False",
"usrName|Fullname|False|0|False|False",
]
我想匹配项目中的情节/优化代码中 。我已经写了这条代码行,
searchResult.Filter(x => x.Users.MatchContained(k=> k.Split('|')[3], "0"));
我试图让所有用户在“管道”上分开后,我在索引3上得到0。我没有得到结果,我没有得到一个例外。
我在这里做错了什么?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您忽略了很多细节,因此我的假设
用户
是ilist< string>用户
我们不知道的是,还有
无论如何,这无法使用当前系统设计的任何查找API解决。取而代之的是,您需要依靠LINQ来解析结果,但是可能不需要发现实现。
这将创建并返回类似于此的对象,因为我使用的是SelectMany,该数组将在整个系统中包含来自搜索结果中匹配页面的所有用户。
如果您出于任何原因要保留或查看某些页面属性,则有其他方法在选择中构造一个新对象,并删除在不匹配的用户
如果您想继续使用此类实现,则必须比使用定界符的字符串以更好的方式存储数据。
Since you left out A LOT of details these are my assumptions
Users
is anIList<string> Users
What we don't know is, among others
Anyway, this cannot be solved using any Find API with the current system design. Instead you need to rely on linq to parse the result, but then the Find implementation may not be necessary.
This would create and return an object similar to this, since I'm using SelectMany the array would contain all users throughout the systems where there are matched pages from the search result.
If you for whatever reason would like to keep or see some page properties there are alternative approaches where you construct a new object within a select and remove any object where there where not matched users
If you like to keep using Find for this kind of implementations you must store the data in a better way than strings with delimiters.