Use iesi. Collections. dll

Source: Internet
Author: User

Because the. NET Framework does not provide the set operation function, we can use a third-party class library to implement this function (now with the LINQ, it is much more convenient ). There is an iesi. collection. dll in the Nhibernate framework. This Class Library provides the set operation function and supports generics.

Function: obtains the same, different, and connected parts of two sets. Example:
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 ("Girl and PM: <br/>"); foreach (string s in girlpms) {response. write (S + "<br/>");} response. write ("<br/>"); Iset <string> girlnotpms = girls. minus (PMS); response. write ("is a girl and not pm: <br/>"); foreach (string s in girlnotpms) {response. write (S + "<br/>");} response. write ("<br/>"); Iset <string> girlorpms = girls. union (PMS); response. write ("is a girl or PM: <br/>"); foreach (string s in girlorpms) {response. write (S + "<br/>");} response. write ("<br/>"); Iset <string> notmatch = girls. exclusiveor (PMS); response. write ("girl, not pm, or PM, but not girl: <br/>"); foreach (string s in notmatch) {response. write (S + "<br/> ");}}}

 

Running result:

Is a girl and PM:
Eva
Novia
Winnie

It's a girl and not a PM:
Christine
Jean

Is a girl or PM:
Christine
Eva
Jean
Novia
Winnie
Vincent
Williams

It's a girl but not a PM, or a PM but not a girl:
Christine
Williams
Jean
Vincent

Supplement: 1. If order is important, hashedset can be changed to sortedset2. if sortedset is used, the elements in the set must inherit the icomparable interface.

3. For more details, refer
Add support for "set" collections to. net

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.