public static class IEnurambleExtension
{
public static IEnumerable<TSource> DistinctBy<TSource, TKey>
(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
HashSet<TKey> keys = new HashSet<TKey>(); foreach (TSource element in source)
if (keys.Add(keySelector(element)))
yield return element;
} public static IEnumerable<int> DistinctByReturnIndexes<TSource, TKey>
(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
HashSet<TKey> keys = new HashSet<TKey>();
int i = ;
foreach (TSource element in source)
{
if (!keys.Add(keySelector(element)))
yield return i;
i++;
}
} public static int FirstContainsWithIndex<TSource>
(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
{
int i = ;
foreach (TSource element in source)
{
if (predicate(element))
return i;
i++;
} return -;
} public static IEnumerable<int> ContainsReturnIndexes<TSource>
(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
{
int i = ;
foreach (TSource element in source)
{
if (predicate(element))
yield return i;
i++;
}
} public static void Print<TSource, TKey>
(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
foreach (TSource element in source)
Console.WriteLine(keySelector(element));
}
}

Customer IEnuramble Extension的更多相关文章

  1. Extension Method[下篇]

    四.Extension Method的本质 通过上面一节的介绍,我们知道了在C#中如何去定义一个Extension Method:它是定义在一个Static class中的.第一个Parameter标 ...

  2. SAP Hybris Commerce启用customer coupon的前提条件

    今天在工作中,我发现一个问题:在SAP帮助文档里,backoffice coupon 维护界面有个 Customer Assignment的区域: 而我工作的Hybris服务器上的backoffice ...

  3. 如何把SAP Kyma和SAP Cloud for Customer连接起来

    首先进入SAP Cloud for Customer的Administration的工作中心,打开General Settings视图,进入Event Notification配置UI: 新建一个C4 ...

  4. EFCore之SQL扩展组件BeetleX.EFCore.Extension

    ​        EFCore是.NETCore团队开发的一个ORM组件,但这个组件在执行传统SQL的时候并不方便,因此BeetleX.EFCore.Extension的设计目的是让EFCore执行传 ...

  5. Windbg Extension NetExt 使用指南 【2】 ---- NetExt 的基本命令介绍

    摘要 : 本章节介绍NetExt常用的命令. 并且对SOS进行一些对比. NetExt的帮助 要想玩好NetExt, 入门就得看帮助. 看NetExt的帮助可以调用!whelp 命令. 这样hi列举出 ...

  6. Windbg Extension NetExt 使用指南 【1】 ---- NetExt 介绍

    摘要 : 在使用WINDBG做debugging的时候,需要一个好的工具帮助进行数据分析. 最常见的extension包括SOS, PSSCOR.  NetExt则是另外一种提供了丰富命令功能的deb ...

  7. 「译」JUnit 5 系列:扩展模型(Extension Model)

    原文地址:http://blog.codefx.org/design/architecture/junit-5-extension-model/ 原文日期:11, Apr, 2016 译文首发:Lin ...

  8. PHPmailer关于Extension missing: openssl报错的解决

    最近在写一个网页的时候,需要用到PHPmailer来发送邮件,按照官网上给出的demo写出一个例子,却报错Extension missing: openssl 最后发现需要修改php.ini中的配置: ...

  9. 研究Extension和Category的一个例子

    Category: 1. 无法添加实例变量 2.将类的实现分散到多个不同文件或多个不同框架中. Extension: 1. 可以添加实例变量 注: 如果Category的头文件中也使用Extensio ...

随机推荐

  1. 第七天:JS内置对象-String字符串对象

    1.String对象  String对象用于处理已有的字符串 字符串可以使用双引号或单引号 String对象有一些常用的方法和属性,例如length 示例代码: <!DOCTYPE html&g ...

  2. linux下卸载mysql

    卸载mysql rpm -qa|grep -i mysql rpm -ev MySQL-server-4.0.14-0 MySQL-client-4.0.14-0 卸载后/var/lib/mysql中 ...

  3. Html5文件

    HTML5 file api 读取文件MD5码 http://www.zhuwenlong.com/blog/52d6769f93dcae3050000003

  4. jquery 插件原则

    区分开 Dom 对象,jQuery Dom对象, Json数据. Dom对象是诸如: document.getElementById 返回的原生Dom对象. jQuery Dom对象,如:$(&quo ...

  5. C#与数据库访问技术总结(七)综合示例

    综合示例 说明:前面介绍了那么多,光说不练假把式,还是做个实例吧. 表:首先你要准备一张表,这个自己准备吧.我们以学生表为例. 1.ExecuteScalar方法 ExecuteScalar方法执行返 ...

  6. Spring基本概念

    spring优点: 1降低组件间耦合度,实现软件各层之间的解耦. 2可以使用容器提供的各种服务.如,事务管理服务,消息服务等等. 当我们使用容器管理事务时,开发人员就不再需要手工控制事务,也不需处理复 ...

  7. windows下安装mingw

    windows环境下使用gcc MinGw是Minimal GNU on Windows的缩写,允许在GNU/linux和windows平台生成本地的windows程序而不需要第三方运行时库.本文主要 ...

  8. paip.python连接mysql最佳实践o4

    paip.python连接mysql最佳实践o4 python连接mysql 还使用了不少时间...,相比php困难多了..麻烦的.. 而php,就容易的多兰.. python标准库没mysql库,只 ...

  9. JAVA开发工具eclipse中@author怎么改

    1:JAVA开发工具eclipse中@author怎么改,开发的时候为了注明版权信息. 用eclipse开发工具默认的是系统用户,那么怎么修改呢 示例如图所示 首先打开Eclipse--->然后 ...

  10. [转]Oracle因安装时未设定字符集导致中文乱码的解决方案

    在CentOS 6.4上安装Oracle 11g没有设定字符集,采用的是操作系统默认字符集:WE8MSWIN1252,将字符集修改为:AL32UTF8. SQL> select userenv( ...