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

  • 相关阅读:
    https 证书
    js 压缩
    身份证认证
    在 Visual Studio 2015 中关闭系统级的 Runtime Exceptions
    在 Visual Studio 2015 中关闭 Browser Link
    List<T>.ForEach()的使用
    使用Microsoft.Practices.EnterpriseLibrary.Validation.dll验证类成员
    jQuery.filter()的强大功能
    jQuery Checkbox Selected
    Get SQL String From Query Object In Entity Framework
  • 原文地址:https://www.cnblogs.com/wenjl520/p/1957975.html
Copyright © 2011-2022 走看看