将对象强制转换为字符串数组
本文关键字:字符串 数组 转换 对象 | 更新日期: 2023-09-27 18:09:45
我有这样的代码:
Strutture = from Ricettivito s in Strutture
where s.ServiziAttivi.Cast<string>().Intersect(IDSServizi).Count() == IDSServizi.Count()
select s;
I need to:
- 将ServiziAttivi(它是MyService的列表)转换为字符串列表(必须包含MyService. uniqueid)
- 然后,检查该列表是否包含IDSServizi的每个元素(这是一个字符串列表)。
但似乎我不能指向转换?
首先转换为.Cast<Ricettivita.MyService>()
,然后选择字符串属性
where s.ServiziAttivi
.Cast<Ricettivita.MyService>()
.Select(x=>x.UniqueID).Intersect(IDSServizi).Count()
我认为你应该用Select
代替Cast
:
Strutture = from Ricettivito s in Strutture
where s.ServiziAttivi.Select(x => (string)x.UniqueID).Intersect(IDSServizi).Count() == IDSServizi.Count()
select s;