我想了解RXJS采摘和地图之间的区别.
谁能帮我这个?
赞赏
我写了跳过最后一个方法.当我用int数组调用它时,我希望只返回2个元素,而不是4个元素.
怎么了?
谢谢
public static class myclass
{
public static IEnumerable<T> SkipLast<T>(this IEnumerable<T> source, int n)
{
return source.Reverse().Skip(n).Reverse();
}
}
class Program
{
static void Main(string[] args)
{
int [] a = new int[] {5, 6, 7, 8};
ArrayList a1 = new ArrayList();
a.SkipLast(2);
for( int i = 0; i <a.Length; i++)
{
Console.Write(a[i]);
}
}
}
Run Code Online (Sandbox Code Playgroud)