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

  • 相关阅读:
    pymongo
    活动专题,各种手机的适配
    怎么判断是qq浏览器还是uc浏览器?
    并的用法,存在并执行~~
    window.location.href在微信端不起作用的解决方法?
    div双击全屏,再双击恢复到原来的状态vue,js来做
    avalon结合原生js tab切换
    vue指令大全~~~
    jquery中$.get()如何让跨域请求携带cookie?
    git 的使用方法以及要注意的地方~/git stash的使用
  • 原文地址:https://www.cnblogs.com/wenjl520/p/1957975.html
Copyright © 2011-2022 走看看