{"id":274025,"date":"2016-02-10T18:16:01","date_gmt":"2016-02-10T15:16:01","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=274025"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=274025","title":{"rendered":"\u041a\u0430\u0432\u0435\u0440\u0437\u043d\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u043e C#"},"content":{"rendered":"\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/ffb\/ca7\/424\/ffbca742462740d49b88e90690f69d91.jpg\" \/><\/div>\n<p>  \u0425\u043e\u0447\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e <s>\u043a\u043e\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u0443\u043f\u043b\u0435<\/s> \u043a\u0430\u0432\u0435\u0440\u0437\u043d\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u043e C#.<br \/>  \u041d\u0435 \u0443\u0434\u0435\u0440\u0436\u0430\u043b\u0441\u044f \u0438 \u0440\u0435\u0448\u0438\u043b \u0437\u0430\u043f\u043e\u0441\u0442\u0438\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0438\u043a\u0438.<br \/>  \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0432 \u043f\u043e\u0434\u0431\u043e\u0440\u043a\u0435 \u043a\u043e\u043c\u0443-\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438, \u043d\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u043e\u0434\u0432\u043e\u0445 \u0432 \u043d\u0438\u0445, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0435\u0441\u0442\u044c. \u0418\u043d\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c \u043f\u043e\u0434\u043b\u043e\u0432\u0438\u0442\u044c. \u0411\u0443\u0434\u0443\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u0442\u0435\u043c, \u043a\u0442\u043e \u0438\u0437\u0443\u0447\u0430\u0435\u0442 \u044f\u0437\u044b\u043a.<br \/>  \u0412\u0441\u0435\u0445, \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442!<br \/>  <a name=\"habracut\"><\/a><br \/>  <b>1<\/b> \u041a\u0430\u043a\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430? <\/p>\n<pre><code class=\"cs\">   static String str;    static DateTime time;          static void Main(string[] args)         {             Console.WriteLine(str == null ? &quot;str == null&quot; : str);             Console.WriteLine(time == null ? &quot;time == null&quot; : time.ToString());             Console.ReadLine();         } <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0442\u0432\u0435\u0442<\/b><\/p>\n<div class=\"spoiler_text\"><b>str == null<br \/>  1\/1\/0001 12:00:00 AM<\/b><br \/>  \u041e\u0431\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043d\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u043d\u043e string \u044d\u0442\u043e \u0441\u0441\u044b\u043b\u043e\u0447\u043d\u044b\u0439\/reference \u0442\u0438\u043f (\u0435\u0441\u043b\u0438 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u044b\u043c, \u0442\u043e \u044d\u0442\u043e immutable \u0442\u0438\u043f, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 reference \u0442\u0438\u043f \u0441 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u043a\u043e\u0439 value \u0442\u0438\u043f\u0430), \u0430 DateTime \u044d\u0442\u043e \u0442\u0438\u043f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\/value type. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0435\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 DateTime \u044d\u0442\u043e 12:00 1 \u044f\u043d\u0432\u0430\u0440\u044f 1 \u0433\u043e\u0434\u0430.  <\/div>\n<\/div>\n<p>  <b>2<\/b> \u041f\u043e\u0438\u0433\u0440\u0430\u0435\u043c \u0441 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c. \u0427\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u043e \u043d\u0430 \u044d\u043a\u0440\u0430\u043d?<\/p>\n<pre><code class=\"cs\">        class A         {             public void abc(int q)             {                 Console.WriteLine(&quot;abc \u0438\u0437 A&quot;);             }         }          class B : A         {             public void abc(double p)             {                 Console.WriteLine(&quot;abc \u0438\u0437 B&quot;);             }         }          static void Main(string[] args)         {             int i = 5;             B b = new B();             b.abc(i);             Console.ReadLine();         } <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0442\u0432\u0435\u0442<\/b><\/p>\n<div class=\"spoiler_text\"><b>abc \u0438\u0437 B<\/b>  <\/div>\n<\/div>\n<p>  <b>3<\/b> \u041f\u043e\u0445\u043e\u0436\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441. \u0427\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c?<\/p>\n<pre><code class=\"cs\">        class P         { }         class Q : P         { }          class A         {             public void abc(Q q)             {                 Console.WriteLine(&quot;abc \u0438\u0437 A&quot;);             }         }          class B : A         {             public void abc(P p)             {                 Console.WriteLine(&quot;abc \u0438\u0437 B&quot;);             }         }          static void Main(string[] args)         {             B b = new B();             b.abc(new Q());             Console.ReadLine();         }  <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0442\u0432\u0435\u0442<\/b><\/p>\n<div class=\"spoiler_text\"><b>abc \u0438\u0437 B<\/b><br \/>  \u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043f\u0440\u043e\u0448\u043b\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c.  <\/div>\n<\/div>\n<p>  <b>4<\/b> \u0422\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u00ab\u0440\u0430\u0437\u0432\u043e\u0434\u00bb \u043d\u0430 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c\u0430. \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0438 \u043d\u0435 \u0443\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0438\u0437 \u0432\u0438\u0434\u0443.<br \/>  \u041a\u0430\u043a\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430?<\/p>\n<pre><code class=\"cs\">    class Program     {         static void Main(string[] args)         {             MyClassB b = new MyClassB();             MyClassA a = b;             a.abc();             Console.ReadLine();         }     }      class MyClassA     {         public MyClassA()         {             Console.WriteLine(&quot;constructor A&quot;);         }          public void abc()         {             Console.WriteLine(&quot;A&quot;);         }     }      class MyClassB:MyClassA     {         public MyClassB()         {             Console.WriteLine(&quot;constructor B&quot;);         }          public void abc()         {             Console.WriteLine(&quot;B&quot;);         }     } <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0442\u0432\u0435\u0442<\/b><\/p>\n<div class=\"spoiler_text\"><b>constructor A<br \/>  constructor B<br \/>  A<\/b><br \/>  \u041f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 B \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043a\u043b\u0430\u0441\u0441\u0430 \u0410, \u043f\u043e\u0442\u043e\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 B. \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0442\u0438\u043f\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u0410 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f b \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432 \u043d\u0435\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 B. \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u043d\u0430 abc() \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u0430 B, \u043d\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 B \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 \u0443 \u043c\u0435\u0442\u043e\u0434\u0430 abc, \u0442\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0447\u0442\u043e \u043e\u043d \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 abc \u0438\u0437 \u043a\u043b\u0430\u0441\u0441\u0430 A. \u041f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0438 abc() \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 B \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u043d\u0443\u0442\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442 new.  <\/div>\n<\/div>\n<p>  <b>5<\/b> \u0423 \u043c\u0435\u043d\u044f \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0432\u043e\u0442 \u043a\u043b\u0430\u0441\u0441:<\/p>\n<pre><code class=\"cs\">        public class Point         {             public int X { get; set; }             public int Y { get; set; }             public Point(int xPos, int yPos)             {                 X = xPos;                 Y = yPos;             }         } <\/code><\/pre>\n<p>  \u0418 \u0435\u0441\u0442\u044c 3 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430. \u0421\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0438 \u043f\u043e\u0434\u043e\u0431\u043d\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430? \u0415\u0441\u043b\u0438 \u043d\u0435\u0442, \u0442\u043e \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c?<\/p>\n<pre><code class=\"cs\">            Point ptOne = new Point(15, 20);             Point ptTwo = new Point(40, 50);             Point ptThree = ptOne + ptTwo; <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0442\u0432\u0435\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b, \u0432 \u043a\u043b\u0430\u0441\u0441 Point \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0443 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code class=\"cs\">            public static Point operator +(Point p1, Point p2)             {                 return new Point(p1.X + p2.X, p1.Y + p2.Y);             } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <b>6<\/b> \u041a\u0430\u043a\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430? <\/p>\n<pre><code class=\"cs\">        string result;          private async void btnStart_Click(object sender, RoutedEventArgs e)         {             SaySomething();             txtSomeTextBlock.Text = result;         }          async System.Threading.Tasks.Task&lt;string&gt; SaySomething()         {             await System.Threading.Tasks.Task.Delay(1000);              result = &quot;Hello world!&quot;;             return result;         } <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0442\u0432\u0435\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\u0411\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u0430 \u043f\u0443\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430, \u0430 \u043d\u0435 \u00abHello world!\u00bb. \u0422\u0430\u0441\u043a SaySomething() \u0431\u044b\u043b \u0432\u044b\u0437\u0432\u0430\u043d \u0431\u0435\u0437 await \u0438 \u043f\u043e\u0442\u043e\u043c\u0443 SaySomething \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u0434\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e await, \u0442\u043e \u0435\u0441\u0442\u044c \u0434\u043e \u0441\u0442\u0440\u043e\u043a\u0438 <\/p>\n<pre><code class=\"cs\">await System.Threading.Tasks.Task.Delay(1000); <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a btnStartClick. \u0415\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c await \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 SaySomething(), \u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u043c \u0438 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d \u0442\u0435\u043a\u0441\u0442 \u00abHello world!\u00bb  <\/div>\n<\/div>\n<p>  <b>7<\/b> \u0412\u043e\u043f\u0440\u043e\u0441 \u0438\u0437 \u0440\u0430\u0437\u0440\u044f\u0434\u0430 \u00abmust know\u00bb. \u041a\u0430\u043a\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430?<\/p>\n<pre><code class=\"cs\">    delegate void SomeMethod();          static void Main(string[] args)         {             List&lt;SomeMethod&gt; delList = new List&lt;SomeMethod&gt;();             for (int i = 0; i &lt; 10; i++)             {                 delList.Add(delegate { Console.WriteLine(i); });             }              foreach (var del in delList)             {                 del();             }         } <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0442\u0432\u0435\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442 \u0447\u0438\u0441\u043b\u043e 10 \u0434\u0435\u0441\u044f\u0442\u044c \u0440\u0430\u0437.<br \/>  \u0414\u0435\u043b\u0435\u0433\u0430\u0442 \u0431\u044b\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d 10 \u0440\u0430\u0437. \u041f\u0440\u0438\u0447\u0435\u043c \u0431\u044b\u043b\u0430 \u0432\u0437\u044f\u0442\u0430 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e i. \u0421\u0441\u044b\u043b\u043a\u0430, \u0430 \u043d\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0412\u043e\u0442 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 i. \u042d\u0442\u043e \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u043c\u044b\u043a\u0430\u043d\u0438\u044f (closure)  <\/div>\n<\/div>\n<p>  <b>8<\/b> \u0427\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u043e \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043a\u043e\u0434\u043e\u043c?<\/p>\n<pre><code class=\"cs\">        static bool SomeMethod1()         {             Console.WriteLine(&quot;\u041c\u0435\u0442\u043e\u0434 1&quot;);             return false;         }         static bool SomeMethod2()         {             Console.WriteLine(&quot;\u041c\u0435\u0442\u043e\u0434 2&quot;);             return true;         }         static void Main(string[] args)         {             if (SomeMethod1() & SomeMethod2())             {                 Console.WriteLine(&quot;\u0431\u043b\u043e\u043a if \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d&quot;);             }         } <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0442\u0432\u0435\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\u041c\u0435\u0442\u043e\u0434 1<br \/>  \u041c\u0435\u0442\u043e\u0434 2<br \/>  \u0411\u043b\u043e\u043a if \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442, \u0442\u0430\u043a \u043a\u0430\u043a SomeMethod1 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 false. \u041d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &#038;, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043e \u0438 \u0432\u0442\u043e\u0440\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u2013 SomeMethod2. \u0415\u0441\u043b\u0438 \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 &#038;&#038;, \u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430.  <\/div>\n<\/div>\n<p>  <b>9<\/b> \u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0441\u0442\u043e\u0439 (\u0434\u0430\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0431\u043e\u0440\u043e\u0434\u0430\u0442\u044b\u0439) \u0432\u043e\u043f\u0440\u043e\u0441. \u0427\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430? <\/p>\n<pre><code class=\"cs\">            double e = 2.718281828459045;             object o = e; \/\/ box             int ee = (int)o; <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0442\u0432\u0435\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435. \u0425\u043e\u0442\u044f \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u0430\u0441\u0442\u0438\u043d\u0433 (casting \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435 \u0432\u044b\u0440\u0430\u0436\u0430\u044f\u0441\u044c explicit conversion) \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0440\u044f\u0435\u0442 \u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0447\u0438\u0441\u043b\u0430.<\/p>\n<pre><code class=\"cs\">            double e = 2.718281828459045;             int ee = (int)e; <\/code><\/pre>\n<p>  \u041d\u043e \u043f\u0440\u0438 unboxing-\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u0418 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e.<br \/>  \u0410 \u0432\u043e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439, \u0441\u0434\u0435\u043b\u0430\u0435\u0442 unboxing \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043a\u0438<\/p>\n<pre><code class=\"cs\">            int ee = (int)(double)o;  <\/code><\/pre>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0442\u0430\u043a\u0436\u0435 \u0441\u043f\u0435\u0440\u0432\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 o \u043a \u0442\u0438\u043f\u0443 dynamic \u0438 \u0437\u0430\u0442\u0435\u043c \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u0442 \u0443\u0436\u0435 casting, \u0430 \u043d\u0435 unboxing:<\/p>\n<pre><code class=\"cs\">            int ee = (int)(o as dynamic); <\/code><\/pre>\n<p>  \u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u043e\u043d \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u0435\u043d \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043a\u043e\u0434\u0443:<\/p>\n<pre><code class=\"cs\">     int ee = (int)(o is dynamic ? (dynamic)o : (dynamic)null); <\/code><\/pre>\n<p>  \u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u0435\u043d \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0443:<\/p>\n<pre><code class=\"cs\">            int ee = (int)(dynamic)o; <\/code><\/pre>\n<p>  \u0445\u043e\u0442\u044f, \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u043c \u0442\u0440\u044e\u043a\u043e\u043c.  <\/div>\n<\/div>\n<p>  <b>10<\/b> \u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430?<\/p>\n<pre><code class=\"cs\">            float q = float.MaxValue;             float w = float.MaxValue;              checked             {                 float a = q * w;                 Console.WriteLine(a.ToString());             } <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0442\u0432\u0435\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\u041d\u0430 \u044d\u043a\u0440\u0430\u043d \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u043e:<br \/>  <b>Infinity<\/b><br \/>  float \u0438 double \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (integral types) \u0438 \u043f\u043e\u0442\u043e\u043c\u0443 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f checked \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442. \u0425\u043e\u0442\u044f \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 int, byte, short \u0438\u043b\u0438 long \u0442\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0431\u044b \u043e\u0448\u0438\u0431\u043a\u0430. Unchecked \u0442\u0430\u043a\u0436\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043d\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"cs\">            decimal x = decimal.MaxValue;             decimal y = decimal.MaxValue;              unchecked             {                 decimal z = x * y;                 Console.WriteLine(z.ToString());             } <\/code><\/pre>\n<p>  \u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 System.OverflowException  <\/div>\n<\/div>\n<p>  <b>11<\/b> \u041c\u043e\u0436\u043d\u043e \u0435\u0449\u0435 \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c \u0441 \u0442\u0438\u043f\u043e\u043c decimal. \u0415\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u043e \u043d\u0430 \u044d\u043a\u0440\u0430\u043d, \u0442\u043e \u0447\u0442\u043e?<\/p>\n<pre><code class=\"cs\">            int x = 5;             decimal y = x \/ 12;             Console.WriteLine(y.ToString()); <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0442\u0432\u0435\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\u042d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 0 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e \u0447\u0442\u043e x \u043f\u043e\u043b\u0435\u043d\u0438\u043b\u0438\u0441\u044c \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0442\u0438\u043f\u0443 decimal. \u0422\u0430\u043a \u043a\u0430\u043a x \u0443 \u043d\u0430\u0441 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u0442\u043e \u043f\u0440\u0438 \u0434\u0435\u043b\u0435\u043d\u0438\u0438 5 \u043d\u0430 12 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0447\u0435\u043c 1, \u0437\u043d\u0430\u0447\u0438\u0442 \u044d\u0442\u043e \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0439 \u043d\u043e\u043b\u044c. \u0412\u0435\u0440\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0430:<\/p>\n<pre><code class=\"cs\">   decimal y = (decimal)x \/ 12; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <b>12<\/b> \u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"cs\">            double d=5.15;             d = d \/ 0;              float f = 5.15f;             f = f \/ 0;              decimal dc = 5.12m;             dc = dc \/ 0; <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0442\u0432\u0435\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\u0414\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 0 \u0442\u0438\u043f\u043e\u0432 double \u0438 float \u0432\u0435\u0440\u043d\u0435\u0442 Infinity, \u0430 \u0432\u043e\u0442 decimal \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 System.DivideByZeroException<\/p>\n<p>  \u041d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u043a\u043e\u0440\u043e\u0442\u0435\u043d\u044c\u043a\u043e \u043e \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f\u0445 \u043c\u0435\u0436\u0434\u0443 decimal, double \u0438 float:<br \/>  <b>decimal<\/b> (128-\u0431\u0438\u0442\u043d\u044b\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e 28\u201329 \u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u044f\u0442\u043e\u0439) \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0444\u0438\u043d\u0430\u043d\u0441\u043e\u0432\u044b\u0445 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0446\u0438\u044f\u0445 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u0440\u0438 \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u0438<br \/>  <b>double<\/b> (64-\u0431\u0438\u0442\u043d\u044b\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e 15\u201316 \u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u044f\u0442\u043e\u0439) \u2014 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0442\u0438\u043f \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0437\u0430\u043f\u044f\u0442\u043e\u0439. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 (\u043a\u0440\u043e\u043c\u0435 \u0444\u0438\u043d\u0430\u043d\u0441\u043e\u0432\u044b\u0445)<br \/>  <b>float<\/b> (32-\u0431\u0438\u0442\u043d\u044b\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e 7 \u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u044f\u0442\u043e\u0439) \u2014 \u0442\u0438\u043f \u0441 \u0441\u0430\u043c\u043e\u0439 \u043d\u0438\u0437\u043a\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0438 \u0441\u0430\u043c\u044b\u043c \u043d\u0438\u0437\u043a\u0438\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u043c, \u0437\u0430\u0442\u043e \u0441 \u0441\u0430\u043c\u043e\u0439 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u0438 \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u0438\u044f\u0445. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u043d\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u0440\u0430\u0441\u0447\u0435\u0442\u043e\u0432.  <\/div>\n<\/div>\n<p>  <b>13<\/b> \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0439 \u0432\u043e\u0442 \u043c\u0435\u0442\u043e\u0434:<\/p>\n<pre><code class=\"cs\">int SomeMethod(int x, int y)     {         return (x - y) * (x + y);     } <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">SomeMethod(y:17, x:21) <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0442\u0432\u0435\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\u0414\u0430, \u043c\u043e\u0436\u043d\u043e. \u0415\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0438 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">SomeMethod(11, y:27) <\/code><\/pre>\n<p>  \u041d\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">SomeMethod(x:12, 11) <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <b>14<\/b> \u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430?<\/p>\n<pre><code class=\"cs\">        static void Main(string[] args)         {             int someInt;             SomeMethod2(out someInt);             Console.WriteLine(someInt);              SomeMethod1(ref someInt);             Console.WriteLine(someInt);              SomeMethod(someInt);             Console.WriteLine(someInt);              Console.ReadLine();         }           static void SomeMethod(int value)         {             value = 0;         }         static void SomeMethod1(ref int value)         {             value = 1;         }         static void SomeMethod2(out int value)         {             value = 2;         } <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0442\u0432\u0435\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\u041d\u0438\u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442. \u0411\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u043e \u043d\u0430 \u044d\u043a\u0440\u0430\u043d:<br \/>  <b>2<\/b><br \/>  <b>1<\/b><br \/>  <b>1<\/b><br \/>  \u0422\u0430\u043a \u043a\u0430\u043a \u043f\u0435\u0440\u0432\u044b\u043c \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c SomeMethod2 \u0441 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c out, \u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 someInt \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u0430 \u0431\u0435\u0437 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 SomeMethod \u0438\u043b\u0438 SomeMethod1, \u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0431\u044b \u043e\u0448\u0438\u0431\u043a\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<br \/>  \u0422\u0430\u043a \u043a\u0430\u043a SomeMethod \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 ref \u0438\u043b\u0438 out, \u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e, \u0430 \u043d\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 someInt \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f. <br \/>  \u041a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 ref \u0438 out \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435. \u041d\u043e \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443 \u043e\u0431\u044f\u0437\u0430\u043d\u043e \u0431\u044b\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 SomeMethod2 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443 value \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.  <\/div>\n<\/div>\n<p>  <b>15<\/b> \u0421\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0438 \u043a\u043e\u0434?<\/p>\n<pre><code class=\"cs\">        static void Main(string[] args)         {             goto lalala;             int i = 5;             { Console.WriteLine(i); }             lalala:             Console.WriteLine(&quot;\u041f\u0440\u043e\u0449\u0430\u0439, \u0436\u0435\u0441\u0442\u043e\u043a\u0438\u0439 \u043c\u0438\u0440!&quot;);             Console.ReadLine();         } <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0442\u0432\u0435\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\u0414\u0430, \u0445\u043e\u0442\u044c \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e. \u041d\u0430 \u044d\u043a\u0440\u0430\u043d \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e <b>\u041f\u0440\u043e\u0449\u0430\u0439, \u0436\u0435\u0441\u0442\u043e\u043a\u0438\u0439 \u043c\u0438\u0440!<\/b> <br \/>  \u0412\u043d\u0443\u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u043c\u0438 \u0441\u043a\u043e\u0431\u043a\u0430\u043c\u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0443\u044e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c. \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438\u0437 \u044d\u0442\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0431\u0443\u0434\u0443\u0442 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432\u043d\u0435 \u0435\u0435. \u0422\u043e \u0435\u0441\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0432\u043e\u0442 \u043a\u043e\u0434 \u043d\u0435 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f:<\/p>\n<pre><code class=\"cs\">        static void Main(string[] args)         {             { int i = 10; }             Console.WriteLine(i);         } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043d\u0438 \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u043d\u043e goto \u0432 C# \u0432\u0441\u0435 \u0435\u0449\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f. \u0425\u043e\u0442\u044f \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u043d\u0443\u0436\u0435\u043d.  <\/div>\n<\/div>\n<p>  <b>16<\/b> \u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0434\u043e\u0441\u043b\u043e\u0432\u043d\u044b\u0435\/\u0442\u043e\u0447\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 (verbatim strings)?<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0442\u0432\u0435\u0442<\/b><\/p>\n<div class=\"spoiler_text\">\u0412\u0441\u0435 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u0437\u043d\u0430\u044e\u0442 \u0447\u0442\u043e \u044d\u0442\u043e \u0437\u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0438\u0445, \u043d\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435 \u0437\u043d\u0430\u044e\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435.<br \/>  Verbatim strings \u2014 \u044d\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0441 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 @ \u0438 \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f escape-\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<br \/>  \u041a\u0430\u043a \u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u2014 \u0434\u043e\u0441\u043b\u043e\u0432\u043d\u044b\u0435 \u0438\u043b\u0438 \u0442\u043e\u0447\u043d\u044b\u0435 \u044d\u0442\u043e \u0443\u0436\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441.  <\/div>\n<\/div>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/275789\/\"> https:\/\/habrahabr.ru\/post\/275789\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/ffb\/ca7\/424\/ffbca742462740d49b88e90690f69d91.jpg\" \/><\/div>\n<p>  \u0425\u043e\u0447\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e <s>\u043a\u043e\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u0443\u043f\u043b\u0435<\/s> \u043a\u0430\u0432\u0435\u0440\u0437\u043d\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u043e C#.<br \/>  \u041d\u0435 \u0443\u0434\u0435\u0440\u0436\u0430\u043b\u0441\u044f \u0438 \u0440\u0435\u0448\u0438\u043b \u0437\u0430\u043f\u043e\u0441\u0442\u0438\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0438\u043a\u0438.<br \/>  \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0432 \u043f\u043e\u0434\u0431\u043e\u0440\u043a\u0435 \u043a\u043e\u043c\u0443-\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438, \u043d\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u043e\u0434\u0432\u043e\u0445 \u0432 \u043d\u0438\u0445, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0435\u0441\u0442\u044c. \u0418\u043d\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c \u043f\u043e\u0434\u043b\u043e\u0432\u0438\u0442\u044c. \u0411\u0443\u0434\u0443\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u0442\u0435\u043c, \u043a\u0442\u043e \u0438\u0437\u0443\u0447\u0430\u0435\u0442 \u044f\u0437\u044b\u043a.<br \/>  \u0412\u0441\u0435\u0445, \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442!  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-274025","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/274025","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=274025"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/274025\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=274025"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=274025"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=274025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}