<?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%2FCSharp_Tutorial%2FLINQ%2FTake</id>
		<title>Csharp/CSharp Tutorial/LINQ/Take - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FLINQ%2FTake"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/LINQ/Take&amp;action=history"/>
		<updated>2026-04-30T00:12:33Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/LINQ/Take&amp;diff=6174&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/LINQ/Take&amp;diff=6174&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:53Z</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/CSharp_Tutorial/LINQ/Take&amp;diff=6175&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/LINQ/Take&amp;diff=6175&amp;oldid=prev"/>
				<updated>2010-05-26T12:18:28Z</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;==Get the first four element in the list==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;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;
using System.Linq.Expressions;&lt;br /&gt;
using System.Xml.Linq;&lt;br /&gt;
    class Program&lt;br /&gt;
    {&lt;br /&gt;
        static void Main(string[] args)&lt;br /&gt;
        {&lt;br /&gt;
            int[] integers = { 1, 6, 2, 27, 10 };&lt;br /&gt;
            &lt;br /&gt;
            IEnumerable&amp;lt;int&amp;gt; firstFourNumbers = integers.Take(4);&lt;br /&gt;
            Console.WriteLine(&amp;quot;First 4 numbers:&amp;quot;);&lt;br /&gt;
            foreach (var num in firstFourNumbers)&lt;br /&gt;
            {&lt;br /&gt;
              Console.WriteLine(num);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Nested Take==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;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;Customer&amp;gt; customers = GetCustomerList();&lt;br /&gt;
        var first3WAOrders = (&lt;br /&gt;
            from c in customers&lt;br /&gt;
            from o in c.Orders&lt;br /&gt;
            where c.Region == &amp;quot;R1&amp;quot;&lt;br /&gt;
            select new { c.CustomerId, o.Id, o.OrderDate })&lt;br /&gt;
            .Take(3);&lt;br /&gt;
        Console.WriteLine(&amp;quot;First 3 orders in WA:&amp;quot;);&lt;br /&gt;
        foreach (var order in first3WAOrders) {&lt;br /&gt;
            Console.WriteLine(order);&lt;br /&gt;
        }&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;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Partitioning Operators: uses Take to generate a sequence of the first three elements of an integer array.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;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[] numbers = { 5, 4, 1, 3, 9};&lt;br /&gt;
        var first3Numbers = numbers.Take(3);&lt;br /&gt;
        Console.WriteLine(&amp;quot;First 3 numbers:&amp;quot;);&lt;br /&gt;
        foreach (var n in first3Numbers) {&lt;br /&gt;
            Console.WriteLine(n);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Take and SelectMany==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;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;Aaa&amp;quot;, &amp;quot;Art&amp;quot;, &amp;quot;Buch&amp;quot;, &amp;quot;Bushman&amp;quot;, &amp;quot;Carter&amp;quot;, &amp;quot;land&amp;quot;};&lt;br /&gt;
        IEnumerable&amp;lt;char&amp;gt; chars = presidents.Take(5).SelectMany(s =&amp;gt; s.ToArray());&lt;br /&gt;
        foreach (char ch in chars)&lt;br /&gt;
            Console.WriteLine(ch);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Take method==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;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;A&amp;quot;, &amp;quot;A&amp;quot;, &amp;quot;B&amp;quot;, &amp;quot;Bu&amp;quot;, &amp;quot;Car&amp;quot;, &amp;quot;land&amp;quot;};&lt;br /&gt;
        IEnumerable&amp;lt;string&amp;gt; items = presidents.Take(5);&lt;br /&gt;
        foreach (string item in items)&lt;br /&gt;
            Console.WriteLine(item);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Take operator outputs the first x elements, discarding the rest==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        int[] numbers = { 10, 9, 8, 7, 6 };&lt;br /&gt;
        IEnumerable&amp;lt;int&amp;gt; firstThree = numbers.Take(3);     // { 10, 9, 8 }&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use Take==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;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, 2, 3, 4, 5, 6, 7, 8, 9 };&lt;br /&gt;
       var query = numbers.Take(5);&lt;br /&gt;
       var query2 = numbers.Skip(5);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>