简体   繁体   English

asp.net mvc C#List <>删除

[英]asp.net mvc C# List<> Remove

I have this 我有这个

  var RadioMetaKey=((IEnumerable<SepiaWEB.Models.Jobs.JobsMeta>)ViewData["JobMeta"]).Where(m=>m.vcr_JobMetaKey==JobsMeta.vcr_JobMetaKey);   

var a=ViewData["JobMeta"]. as List<SepiaWEB.Models.Jobs.JobsMeta>;

a. RemoveAll(RadioMetaKey);  //not working

Is there a way i can use RadioMetaKey to remove from a list 有没有办法可以使用RadioMetaKey从列表中删除

You can pass a Predicate to RemoveAll : 您可以将谓词传递给RemoveAll

var radioMetaKey=((IEnumerable<SepiaWEB.Models.Jobs.JobsMeta>)ViewData["JobMeta"])
    .Where(m=>m.vcr_JobMetaKey==JobsMeta.vcr_JobMetaKey);   

var a= ViewData["JobMeta"]. as List<SepiaWEB.Models.Jobs.JobsMeta>;
a.RemoveAll(x=> radioMetaKey.Contains(x));

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM