You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何从C#的SomeValue对象列表中仅提取Close属性值?

解决方案

只需要在TakeWhile筛选之后,通过Select操作投影出Close属性即可:

var ydata = series.TakeWhile(x => x.Close == maxItem.Close)
                  .Select(x => x.Close)
                  .ToList();

说明

  • TakeWhile(x => x.Close == maxItem.Close):保留序列中连续满足Close等于maxItem.Close的所有SomeValue对象(注意:一旦遇到不满足条件的元素,就会停止遍历)
  • Select(x => x.Close):将每个筛选后的SomeValue对象转换为它的Close属性值
  • 最终ydata的类型是List<decimal>,完全由你需要的Close数值组成

内容的提问来源于stack exchange,提问作者Jan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 05:22:33