Iesi.Collections.dll的功能介绍
来源:互联网 发布:电脑美图软件 编辑:程序博客网 时间:2024/06/15 19:21
由于.NET框架本身没有提供集合运算功能,在使用这方面的功能时,我们可以借助第三方的类库来实现( 现在有了Linq,那就方便多了)。在NHibernate 框架中有个Iesi.Collection.dll,这个类库提供了集合运算功能,并且支持泛型。
功能: 主要是取得2个集合里,相同、相异、联集的部份。
例子:
- using System;
- using System.Data;
- using System.Configuration;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using Iesi.Collections.Generic;
- public partial class _Default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- ISet<string> Girls = new HashedSet<string>();
- Girls.Add("Christine");
- Girls.Add("Eva");
- Girls.Add("Jean");
- Girls.Add("Novia");
- Girls.Add("Winnie");
- ISet<string> PMs = new HashedSet<string>();
- PMs.Add("Eva");
- PMs.Add("Novia");
- PMs.Add("Vincent");
- PMs.Add("Williams");
- PMs.Add("Winnie");
- ISet<string> GirlPMs = Girls.Intersect(PMs);
- Response.Write("是女生且是PM: <br />");
- foreach (string s in GirlPMs) {
- Response.Write(s + "<br />");
- }
- Response.Write("<br />");
- ISet<string> GirlNotPMs = Girls.Minus(PMs);
- Response.Write("是女生且不是PM: <br />");
- foreach (string s in GirlNotPMs) {
- Response.Write(s + "<br />");
- }
- Response.Write("<br />");
- ISet<string> GirlOrPMs = Girls.Union(PMs);
- Response.Write("是女生或是PM: <br />");
- foreach (string s in GirlOrPMs) {
- Response.Write(s + "<br />");
- }
- Response.Write("<br />");
- ISet<string> NotMatch = Girls.ExclusiveOr(PMs);
- Response.Write("是女生但不是PM,或是PM但不是女生: <br />");
- foreach (string s in NotMatch) {
- Response.Write(s + "<br />");
- }
- }
- }
运行结果:
是女生且是PM:
Eva
Novia
Winnie
是女生且不是PM:
Christine
Jean
是女生或是PM:
Christine
Eva
Jean
Novia
Winnie
Vincent
Williams
是女生但不是PM,或是PM但不是女生:
Christine
Williams
Jean
Vincent
补充:
1. 如果顺序是重要的,那 HashedSet 可以改成 SortedSet
2. 如果用SortedSet, 集合里面的元素必需继承IComparable接口
3. 更详细的介绍可参考 Add Support for "Set" Collections to .NET
0 0
- Iesi.Collections.dll的功能介绍
- 使用 Iesi.Collections.dll
- 在.Net中进行集合运算(使用 Iesi.Collections.dll)
- 在.Net中进行集合运算(使用 Iesi.Collections.dll)
- 在.Net中进行集合运算(使用 Iesi.Collections.dll)
- 在.Net中进行集合运算(使用 Iesi.Collections.dll)
- 报“未能加载文件或程序集“Iesi.Collections”或它的某一个依赖项。参数错误”的解决方法
- hibernate的collections介绍
- 未能加载文件或程序集“Iesi.Collections”或它的某一个依赖项。参数错误。 (异常来自 HRESULT:0x80070057 (E_INVALIDARG))
- Collections,Arrays的排序功能
- System.Collections 的常用集合介绍
- Java数据结构 Collections的一些方法介绍
- FMOD.dll的介绍
- DLL用法的介绍
- System32下DLL的功能
- google collections介绍
- google collections介绍
- Java collections使用介绍
- Qt中数组多语言
- tftpc
- java堆栈
- 毕业季,记录一下借过的书,虽然掌握的很少
- javascript 预编译
- Iesi.Collections.dll的功能介绍
- CXF之JAX-WS
- 电视媒体雪崩
- Windows2003 建立WEB服务器
- opencv利用鼠标获取像素值
- fstream和ifstream详细用法,c++文件输入输出要注意!!
- 黑马程序员---java学习笔记之字符串
- css4—第4代选择器
- 插入排序