Linq101-CustomSequence
2024-08-25 15:34:08
using System;
using System.Collections.Generic;
using System.Linq; namespace Linq101
{
class CustomSequence
{
public void Linq98()
{
int[] vectorA = { , , , , };
int[] vectorB = { , , , , }; int result = vectorA.Combine(vectorB, (a, b) => a * b).Sum();
Console.WriteLine(result);
}
} public static class CustomSequenceOperators
{
public static IEnumerable<int> Combine(this IEnumerable<int> first, IEnumerable<int> second, Func<int, int, int> func)
{
//List<int> list=new List<int>();
using (IEnumerator<int> e1 = first.GetEnumerator(), e2 = second.GetEnumerator())
{
while (e1.MoveNext() && e2.MoveNext())
{
yield return func(e1.Current, e2.Current);
//list.Add(func(e1.Current, e2.Current));
}
}
//return list;
}
}
}
最新文章
- eclipse报错“Undefined variable from import: ...”解决方案
- git github 异常
- Python: 关于nose
- MongoDB学习(一)简介
- PostgreSQL Type的创建与Type在函数中的使用
- fedora22多媒体编码
- Spring与Hibernate、Mybatis整合
- leetcode169——Majority Element (C++)
- Java 日志缓存机制的实现--转载
- [补] winpcap编程——EAPSOCKET实现校园网锐捷登录(mentohust)
- Robot Framework之测试用例分层实战
- bzoj 2510 弱题 矩阵乘
- Mysql的两种“排名第几且有可能为空的记录”写法(力扣176)
- #254 Check for Palindromes
- pip 解决下载包速度慢的问题
- SpringCloud概述
- 分布式高性能消息系统(Kafka MQ)的原理与实践
- 在 Linux 上搭建IntelliJ IDEA license server服务器
- selenium键盘操作
- Font Awesome(一套很棒的图标库)