Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 订单Ienumerable<;选择列表项>;根据字符串数组_Arrays_Ienumerable_Sql Order By_Linq To Objects_Selectlistitem - Fatal编程技术网

Arrays 订单Ienumerable<;选择列表项>;根据字符串数组

Arrays 订单Ienumerable<;选择列表项>;根据字符串数组,arrays,ienumerable,sql-order-by,linq-to-objects,selectlistitem,Arrays,Ienumerable,Sql Order By,Linq To Objects,Selectlistitem,我需要根据数组中的值排列一个Ienumerable选择列表 我的代码如下所示: model.RequestedSegments = EvaluationServices.GetSegmentlistItems.Where(a => model.RequestedSelectedSegments.Contains(a.Value)); 其中RequestedSegments和RequestedSelectedSegments是模型的成员 声明为: public IEnumerable<

我需要根据数组中的值排列一个Ienumerable选择列表 我的代码如下所示:

model.RequestedSegments = EvaluationServices.GetSegmentlistItems.Where(a => model.RequestedSelectedSegments.Contains(a.Value));
其中RequestedSegments和RequestedSelectedSegments是模型的成员 声明为:

public IEnumerable<SelectListItem> RequestedSegments { get; set; }
public string[] RequestedSelectedSegments { get; set; }
public IEnumerable RequestedSegments{get;set;}
公共字符串[]RequestedSelectedSegments{get;set;}
谢谢,
suraj

我尝试了以下代码,它工作正常:

model.RequestedSegments = from o in model.RequestedSelectedSegments.Select((o, i) => new { Value = o, Index = i }) join f in model.RequestedSegments on o.Value equals f.Value orderby o.Index select f;

我为你自己发布答案而感到高兴。