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

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/delegate/Anonymous_delegate&amp;diff=6574&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/delegate/Anonymous_delegate&amp;diff=6574&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/delegate/Anonymous_delegate&amp;diff=6575&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/delegate/Anonymous_delegate&amp;diff=6575&amp;oldid=prev"/>
				<updated>2010-05-26T12:19:56Z</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;==An anonymous 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;
  &lt;br /&gt;
delegate void Do();  &lt;br /&gt;
  &lt;br /&gt;
class AnonMethDemo {  &lt;br /&gt;
 &lt;br /&gt;
  public static void Main() {   &lt;br /&gt;
     Do count = delegate {  &lt;br /&gt;
      for(int i=0; i &amp;lt;= 5; i++)  &lt;br /&gt;
        Console.WriteLine(i); &lt;br /&gt;
    }; &lt;br /&gt;
 &lt;br /&gt;
    count();  &lt;br /&gt;
  } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;0&lt;br /&gt;
1&lt;br /&gt;
2&lt;br /&gt;
3&lt;br /&gt;
4&lt;br /&gt;
5&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==An anonymous method that returns a value.==&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;
  &lt;br /&gt;
delegate int CountIt(int end);  &lt;br /&gt;
  &lt;br /&gt;
class MainClass {  &lt;br /&gt;
 &lt;br /&gt;
  public static void Main() {   &lt;br /&gt;
    CountIt count = delegate (int end) { &lt;br /&gt;
      Console.WriteLine(&amp;quot;end:&amp;quot;+end);&lt;br /&gt;
      return end;&lt;br /&gt;
    }; &lt;br /&gt;
 &lt;br /&gt;
    int result = count(3); &lt;br /&gt;
    Console.WriteLine(&amp;quot;Summation of 3 is &amp;quot; + result); &lt;br /&gt;
 &lt;br /&gt;
    result = count(5);  &lt;br /&gt;
    Console.WriteLine(&amp;quot;Summation of 5 is &amp;quot; + result); &lt;br /&gt;
  } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;end:3&lt;br /&gt;
Summation of 3 is 3&lt;br /&gt;
end:5&lt;br /&gt;
Summation of 5 is 5&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==An anonymous method that takes an argument.==&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;
  &lt;br /&gt;
delegate void CountIt(int end);  &lt;br /&gt;
  &lt;br /&gt;
class MainClass {  &lt;br /&gt;
 &lt;br /&gt;
  public static void Main() {   &lt;br /&gt;
    CountIt count = delegate (int end) { &lt;br /&gt;
        Console.WriteLine(&amp;quot;end:&amp;quot;+end); &lt;br /&gt;
    }; &lt;br /&gt;
 &lt;br /&gt;
    count(3); &lt;br /&gt;
    count(5);  &lt;br /&gt;
  } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;end:3&lt;br /&gt;
end:5&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Anonymous delegate 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;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
   delegate int FunctionToCall(int InParam);&lt;br /&gt;
   static void Main()&lt;br /&gt;
   {&lt;br /&gt;
      FunctionToCall del = delegate(int x){&lt;br /&gt;
                        return x + 20;&lt;br /&gt;
                     };&lt;br /&gt;
      Console.WriteLine(&amp;quot;{0}&amp;quot;, del(5));&lt;br /&gt;
      Console.WriteLine(&amp;quot;{0}&amp;quot;, del(6));&lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;25&lt;br /&gt;
26&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Anonymous delegate methods==&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.Reflection;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
delegate int IntDelegate(int x);&lt;br /&gt;
public class MainClass&lt;br /&gt;
{&lt;br /&gt;
    static void TransformUpTo(IntDelegate d, int max)&lt;br /&gt;
    {&lt;br /&gt;
        for (int i = 0; i &amp;lt;= max; i++)&lt;br /&gt;
            Console.WriteLine(d(i));&lt;br /&gt;
    }&lt;br /&gt;
   public static void Main(){&lt;br /&gt;
        TransformUpTo(delegate(int x) { return x * x; }, 10);&lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;0&lt;br /&gt;
1&lt;br /&gt;
4&lt;br /&gt;
9&lt;br /&gt;
16&lt;br /&gt;
25&lt;br /&gt;
36&lt;br /&gt;
49&lt;br /&gt;
64&lt;br /&gt;
81&lt;br /&gt;
100&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==anonymous method delegate invocation==&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.Text;&lt;br /&gt;
    class Program&lt;br /&gt;
    {&lt;br /&gt;
        delegate void MessagePrintDelegate(string msg);&lt;br /&gt;
        static void Main(string[] args)&lt;br /&gt;
        {&lt;br /&gt;
&lt;br /&gt;
            MessagePrintDelegate mpd2 = delegate(string msg)&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine(&amp;quot;[Anonymous] {0}&amp;quot;, msg);&lt;br /&gt;
            };&lt;br /&gt;
            LongRunningMethod(mpd2);&lt;br /&gt;
        }&lt;br /&gt;
        static void LongRunningMethod(MessagePrintDelegate mpd)&lt;br /&gt;
        {&lt;br /&gt;
            for (int i = 0; i &amp;lt; 99; i++)&lt;br /&gt;
            {&lt;br /&gt;
                if (i % 25 == 0)&lt;br /&gt;
                {&lt;br /&gt;
                    mpd(string.Format(&amp;quot;Progress Made. {0}% complete.&amp;quot;, i));&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        static void PrintMessage(string msg)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;[PrintMessage] {0}&amp;quot;, msg);&lt;br /&gt;
        }&lt;br /&gt;
    }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Anonymous Methods==&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.Threading;&lt;br /&gt;
&lt;br /&gt;
public delegate void DelegateClass();&lt;br /&gt;
public class Starter {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        DelegateClass del = delegate {&lt;br /&gt;
            Console.WriteLine(&amp;quot;Running anonymous method&amp;quot;);&lt;br /&gt;
        };&lt;br /&gt;
        del();&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create a delegate by declaration==&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.Text;&lt;br /&gt;
class Program {&lt;br /&gt;
    delegate string delegateTest(string val);&lt;br /&gt;
    static void Main(string[] args) {&lt;br /&gt;
        string mid = &amp;quot;, middle part,&amp;quot;;&lt;br /&gt;
        delegateTest d = delegate(string param) {&lt;br /&gt;
            param += mid;&lt;br /&gt;
            param += &amp;quot; and this was added to the string.&amp;quot;;&lt;br /&gt;
            return param;&lt;br /&gt;
        };&lt;br /&gt;
        Console.WriteLine(d(&amp;quot;Start of string&amp;quot;));&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Demonstrate a captured variable.==&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;
  &lt;br /&gt;
delegate int CountIt(int end);&lt;br /&gt;
  &lt;br /&gt;
class MainClass {  &lt;br /&gt;
 &lt;br /&gt;
  static CountIt counter() { &lt;br /&gt;
    CountIt ctObj = delegate (int end) { &lt;br /&gt;
      Console.WriteLine(&amp;quot;end:&amp;quot;+end);&lt;br /&gt;
      return end; &lt;br /&gt;
    }; &lt;br /&gt;
    return ctObj; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  public static void Main() {   &lt;br /&gt;
    CountIt count = counter(); &lt;br /&gt;
 &lt;br /&gt;
    int result = count(3); &lt;br /&gt;
    result = count(5);  &lt;br /&gt;
  } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;end:3&lt;br /&gt;
end:5&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>