<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FLINQ%2FIntersect</id>
		<title>Csharp/C Sharp/LINQ/Intersect - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FLINQ%2FIntersect"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/LINQ/Intersect&amp;action=history"/>
		<updated>2026-04-29T17:58:47Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/LINQ/Intersect&amp;diff=420&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/LINQ/Intersect&amp;diff=420&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:18Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/LINQ/Intersect&amp;diff=421&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/LINQ/Intersect&amp;diff=421&amp;oldid=prev"/>
				<updated>2010-05-26T11:38:22Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Intersect Operator==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        string[] presidents = {&amp;quot;G&amp;quot;, &amp;quot;H&amp;quot;, &amp;quot;a&amp;quot;, &amp;quot;H&amp;quot;, &amp;quot;over&amp;quot;, &amp;quot;Jack&amp;quot;};&lt;br /&gt;
        IEnumerable&amp;lt;string&amp;gt; first = presidents.Take(5);&lt;br /&gt;
        IEnumerable&amp;lt;string&amp;gt; second = presidents.Skip(4);&lt;br /&gt;
        IEnumerable&amp;lt;string&amp;gt; intersect = first.Intersect(second);&lt;br /&gt;
        Console.WriteLine(&amp;quot;The count of the array is: &amp;quot; + presidents.Count());&lt;br /&gt;
        Console.WriteLine(&amp;quot;The count of the first sequence is: &amp;quot; + first.Count());&lt;br /&gt;
        Console.WriteLine(&amp;quot;The count of the second sequence is: &amp;quot; + second.Count());&lt;br /&gt;
        Console.WriteLine(&amp;quot;The count of the intersect sequence is: &amp;quot; + intersect.Count());&lt;br /&gt;
        foreach (string name in intersect)&lt;br /&gt;
            Console.WriteLine(name);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==prints a list of numbers that are common to two integer arrays.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        int[] numbersA = { 0, 2, 4, 5, 6, 8, 9 };&lt;br /&gt;
        int[] numbersB = { 1, 3, 5, 7, 8 };&lt;br /&gt;
        var commonNumbers = numbersA.Intersect(numbersB);&lt;br /&gt;
        Console.WriteLine(&amp;quot;Common numbers shared by both arrays:&amp;quot;);&lt;br /&gt;
        foreach (var n in commonNumbers) {&lt;br /&gt;
            Console.WriteLine(n);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==prints the first letter of a Product name and the first letter of a Customer name.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        List&amp;lt;Product&amp;gt; products = GetProductList();&lt;br /&gt;
        List&amp;lt;Customer&amp;gt; customers = GetCustomerList();&lt;br /&gt;
        var productFirstChars =&lt;br /&gt;
            from p in products&lt;br /&gt;
            select p.ProductName[0];&lt;br /&gt;
        var customerFirstChars =&lt;br /&gt;
            from c in customers&lt;br /&gt;
            select c.rupanyName[0];&lt;br /&gt;
        var commonFirstChars = productFirstChars.Intersect(customerFirstChars);&lt;br /&gt;
        Console.WriteLine(&amp;quot;Common first letters from Product names and Customer names:&amp;quot;);&lt;br /&gt;
        foreach (var ch in commonFirstChars) {&lt;br /&gt;
            Console.WriteLine(ch);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    static List&amp;lt;Product&amp;gt; GetProductList() {&lt;br /&gt;
        List&amp;lt;Product&amp;gt; empTree = new List&amp;lt;Product&amp;gt;();&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;A&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 12, UnitsInStock = 5, Total = 36, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;B&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 2, UnitsInStock = 4, Total = 35, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;C&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 3, Total = 34, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;D&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 0, Total = 33, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;E&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 1112, UnitsInStock = 2, Total = 32, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;F&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 11112, UnitsInStock = 0, Total = 31, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        return empTree;&lt;br /&gt;
    }&lt;br /&gt;
    static List&amp;lt;Customer&amp;gt; GetCustomerList() {&lt;br /&gt;
        List&amp;lt;Product&amp;gt; empTree = new List&amp;lt;Product&amp;gt;();&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;A&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 12, UnitsInStock = 5, Total = 36, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;B&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 2, UnitsInStock = 4, Total = 35, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;C&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 3, Total = 34, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;D&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 0, Total = 33, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;E&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 1112, UnitsInStock = 2, Total = 32, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;F&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 11112, UnitsInStock = 0, Total = 31, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        List&amp;lt;Customer&amp;gt; l = new List&amp;lt;Customer&amp;gt;();&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;A&amp;quot;, Region = &amp;quot;R1&amp;quot;, UnitsInStock = 1, Orders = empTree, CustomerId = 0 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;B&amp;quot;, Region = &amp;quot;R2&amp;quot;, UnitsInStock = 2, Orders = empTree, CustomerId = 1 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;C&amp;quot;, Region = &amp;quot;R3&amp;quot;, UnitsInStock = 3, Orders = empTree, CustomerId = 2 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;D&amp;quot;, Region = &amp;quot;R4&amp;quot;, UnitsInStock = 4, Orders = empTree, CustomerId = 3 });&lt;br /&gt;
        l.Add(new Customer { CompanyName = &amp;quot;E&amp;quot;, Region = &amp;quot;R5&amp;quot;, UnitsInStock = 5, Orders = empTree, CustomerId = 4 });&lt;br /&gt;
        return l;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Customer : IComparable&amp;lt;Customer&amp;gt; {&lt;br /&gt;
    public string CompanyName { get; set; }&lt;br /&gt;
    public string Region { get; set; }&lt;br /&gt;
    public List&amp;lt;Product&amp;gt; Orders { get; set; }&lt;br /&gt;
    public int UnitsInStock { get; set; }&lt;br /&gt;
    public int CustomerId { get; set; }&lt;br /&gt;
    public override string ToString() {&lt;br /&gt;
        return String.Format(&amp;quot;Id: {0}, Name: {1}, Region: {3}&amp;quot;, this.CustomerId, this.rupanyName, this.Region);&lt;br /&gt;
    }&lt;br /&gt;
    int IComparable&amp;lt;Customer&amp;gt;.rupareTo(Customer other) {&lt;br /&gt;
        if (other == null)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.CustomerId &amp;gt; other.CustomerId)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.CustomerId &amp;lt; other.CustomerId)&lt;br /&gt;
            return -1;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Product : IComparable&amp;lt;Product&amp;gt; {&lt;br /&gt;
    public string ProductName { get; set; }&lt;br /&gt;
    public string Category { get; set; }&lt;br /&gt;
    public int UnitPrice { get; set; }&lt;br /&gt;
    public int UnitsInStock { get; set; }&lt;br /&gt;
    public int Total { get; set; }&lt;br /&gt;
    public DateTime OrderDate { get; set; }&lt;br /&gt;
    public int Id { get; set; }&lt;br /&gt;
    public override string ToString() {&lt;br /&gt;
        return String.Format(&amp;quot;Id: {0}, Name: {1} , Category: {3}&amp;quot;, this.Id, this.ProductName, this.Category);&lt;br /&gt;
    }&lt;br /&gt;
    int IComparable&amp;lt;Product&amp;gt;.rupareTo(Product other) {&lt;br /&gt;
        if (other == null)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.Id &amp;gt; other.Id)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.Id &amp;lt; other.Id)&lt;br /&gt;
            return -1;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==use Linq Intersect to intersect two arrays==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
public class MainClass{&lt;br /&gt;
   public static void Main(){&lt;br /&gt;
            int[] numbers = {1, 1, 2, 3, 3};&lt;br /&gt;
            int[] numbers2 = {1, 3, 3, 4};&lt;br /&gt;
            Console.Write(numbers.Intersect(numbers2));&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>