zoukankan      html  css  js  c++  java
  • 主要是取得2個Collection 裏,相同、相異、聯集的部份<转>

    必需加入的dll: Iesi.Collections.dl
    範例:
    代码
    using System;
    using Iesi.Collections.Generic;

    public partial class TestPage_SetDemoPage : 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 />");
            }
        }
    }

     dll下载

    原文地址:http://blog.blueshop.com.tw/uni2tw/archive/2008/02/14/54315.aspx

  • 相关阅读:
    Java实现监控目录下文件变化
    Postgresql 修改用户密码
    Swing清空jtable中的数据
    delphi登录用友的信息
    用友U8的SQL SERVER 数据库结构说明表
    候老师的讲堂:视频录制、笔记软件、思维导图、画图等工具
    DELPHI 关于内存数据与 JSON
    Delphi国内优秀网站及开源项目
    SQL Server 阻止了对组件Ad Hoc Distributed Queries访问的方法
    SQL Server跨服务器查询
  • 原文地址:https://www.cnblogs.com/wenjl520/p/1957975.html
Copyright © 2011-2022 走看看