将14条记录从一个列表拉到另一个 - c#

我在下面创建了以下列表。 rsiCalcList已经填充了我想要的内容,但是我需要将前15个项从rsiCalcList跳过第一项到firstRSICalculationHistInfo。我也附上了我尝试出错的尝试。我还附有以下错误。有关如何实现目标的一些指导

private class rsiCalcList
{
    public string rsiCalcSymbol { get; set; }
    public DateTime rsiCalcDate { get; set; }
    public decimal rsiCalcCloseChange { get; set; }
}

private class firstRSICalculationHistInfo
{
    public string firstRSISymbol { get; set; }
    public DateTime firstRSICalcDate { get; set; }
    public decimal firstRSICloseChange { get; set; }
}

irstRSIHistInfo = rsiCalcList
     .Select(x => new firstRSICalculationHistInfo { firstRSISymbol = x.rsiCalcSymbol, firstRSICalcDate = x.rsiCalcDate, firstRSICloseChange = x.rsiCalcCloseChange })
     .OrderBy(x => x.firstRSICloseChange)
     .Skip(1)
     .Take(15);

错误

Error   CS0266  Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<AfterTrade.RelativeStrengthIndex.firstRSICalculationHistInfo>' to 'System.Collections.Generic.List<AfterTrade.RelativeStrengthIndex.firstRSICalculationHistInfo>'. An explicit conversion exists (are you missing a cast?)   AfterTrade  C:\Users\\Documents\Projects\Stockton\Development\AfterTrade\RelativeStrengthIndex.cs   86  Active

参考方案

使用.ToList()解决您的查询。

irstRSIHistInfo = rsiCalcList
     .Select(x => new firstRSICalculationHistInfo { firstRSISymbol = x.rsiCalcSymbol, firstRSICalcDate = x.rsiCalcDate, firstRSICloseChange = x.rsiCalcCloseChange })
     .OrderBy(x => x.firstRSICloseChange)
     .Skip(1)
     .Take(15)
     .ToList();

与哪些运算符>>兼容 - java

我这里没有什么代码int b=3; b=b >> 1; System.out.println(b); 它可以完美工作,但是当我将变量b更改为byte,short,float,double时,它包含错误,但是对于变量int和long来说,它可以完美工作,为什么它不能与其他变量一起工作? 参考方案 位移位运算符(例如>>)与任何整数类型兼…

>> Python中的运算符 - python

>>运算符做什么?例如,以下操作10 >> 1 = 5有什么作用? 参考方案 它是右移运算符,将所有位“右移”一次。二进制10是1010移到右边变成0101这是5

Linq-在嵌套集合中查找元素 - c#

我有一个通用列表-SupportedTypeGroups。每个SupportedTypeGroup都有SupportedTypes属性(SupportedType的通用列表)。如何构造Linq查询以使用所需名称查找SupportedType? 参考方案 var result = SupportedTypeGroups .SelectMany(g => …

LINQ RemoveAll代替循环 - c#

我有两个for循环,用于从列表中删除项目。我正在为这些循环寻找等效的LINQ语句for (Int32 i = points.Count - 1; i >= 0; i--) { for (Int32 j = touchingRects.Count - 1; j >= 0; j--) { if (touchingRects[j].HitTest(po…

Linq FirstOrDefault评估每次迭代的谓词吗? - c#

如果我有如下声明:var item = Core.Collections.Items.FirstOrDefault(itm => itm.UserID == bytereader.readInt()); 这段代码是在每次迭代时从我的流中读取一个整数,还是只读取一次该整数,将其存储,然后在整个查找过程中使用其值? 参考方案 考虑以下代码: static …