{"id":172329,"date":"2013-03-13T00:25:03","date_gmt":"2013-03-12T20:25:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=172329"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=172329","title":{"rendered":"<span class=\"post_title\">\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e .NET \u0438 C# (\u043e\u0442\u0432\u0435\u0442\u044b \u0441 \u0440\u0430\u0437\u0431\u043e\u0440\u043e\u043c)<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041d\u0430 \u043c\u0438\u043d\u0443\u0432\u0448\u0438\u0445 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u044f \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b \u043f\u043e\u0441\u0442 <a href=\"http:\/\/habrahabr.ru\/post\/135563\/\"><b>\u00ab\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e .NET \u0438 C#\u00bb<\/b><\/a><\/p>\n<p>  \u042f \u0434\u0443\u043c\u0430\u044e \u043c\u043d\u043e\u0433\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u043e\u0442\u0432\u0435\u0442\u044b, \u043d\u043e \u0438 \u0443\u0437\u043d\u0430\u0442\u044c \u043a\u0430\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0437\u043d\u0430\u0435\u0442 \u044d\u0442\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u043e\u0442\u0432\u0435\u0442\u044b. \u0418\u043c\u0435\u043d\u043d\u043e \u0441 \u044d\u0442\u043e\u0439 \u0446\u0435\u043b\u044c\u044e \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0441\u044f \u044d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442.<\/p>\n<p>  \u042f \u043d\u0435 \u043d\u0430\u0441\u0442\u0430\u0438\u0432\u0430\u044e \u043d\u0430 \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0439 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u043a\u0440\u0438\u0442\u0438\u043a\u0430, \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438 \u0443\u0442\u043e\u0447\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442\u0441\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrahabr.zeegin.com\/topic135563\/Csharp.png\" alt=\"image\"\/><\/p>\n<p>  \u041e\u0431\u0435\u0449\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u0432\u0435\u0442\u044b \u0441 \u0440\u0430\u0437\u0431\u043e\u0440\u043e\u043c \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c.<\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrahabr.zeegin.com\/topic172329\/1.bmp\" alt=\"image\"\/><br \/>  <i>\u042d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u043d\u0430\u0434\u0435\u043b\u0430\u043b \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0448\u0443\u043c\u0430 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/i><\/p>\n<p>  \u0412 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 C# \u0441\u043a\u0430\u0437\u0430\u043d\u043e:  <\/p>\n<blockquote><p>The static constructor for a class executes at most once in a given application domain. The execution of a static constructor is triggered by the first of the following events to occur within an application domain:<\/p>\n<p>  An instance of the class is created.<br \/>  Any of the static members of the class are referenced.<\/p><\/blockquote>\n<p>  \u041f\u043e\u0442\u043e\u043c\u0443 \u0441\u0430\u043c\u044b\u0439 \u0431\u043b\u0438\u0437\u043a\u0438\u0439 \u043a \u0438\u0441\u0442\u0438\u043d\u0435 \u043e\u0442\u0432\u0435\u0442: &quot;<i><b>\u041e\u0434\u0438\u043d \u0440\u0430\u0437 \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u043b\u0438 \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0447\u043b\u0435\u043d\u0430\u043c \u043a\u043b\u0430\u0441\u0441\u0430<\/b><\/i>&quot;. \u0425\u043e\u0442\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u043f\u0435\u0440\u0435\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0430 &quot;\u2026 \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u0438&quot; \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0443\u043c\u0435\u0441\u0442\u043d\u0430.<\/p>\n<p>  \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0431\u044b\u0432\u0430\u044e\u0442 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u044f\u0432\u043d\u044b\u0435 (\u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0437\u0430\u0434\u0430\u043d \u044f\u0432\u043d\u043e) \u0438 \u043d\u0435\u044f\u0432\u043d\u044b\u0435 (\u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c). \u0412 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u0442 \u044f\u0432\u043d\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430, \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0444\u043b\u0430\u0433\u043e\u043c <code>beforefieldinit<\/code>, \u0447\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442 CLR \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u0434\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u044e, \u043f\u0440\u0438\u0447\u0435\u043c \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0442\u0438 \u0437\u0430\u0434\u043e\u043b\u0433\u043e \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u0441\u0442\u0430\u0442\u0438, \u043d\u0430 \u044d\u0442\u043e\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043e\u0434\u043d\u0430 \u0438\u0437 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 Singleton&#39;\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">public sealed class Singleton {     static readonly Singleton instance = new Singleton();      \/\/ Explicit static constructor to tell C# compiler     \/\/ not to mark type as beforefieldinit     static Singleton()     {     }      Singleton()     {     }      public static Singleton Instance     {         get         {             return instance;         }     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrahabr.zeegin.com\/topic172329\/2.bmp\" alt=\"image\"\/><\/p>\n<p>  \u0414\u043b\u044f \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439 \u0432 C# \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 <b><i>add<\/i><\/b> \u0438 <b><i>remove<\/i><\/b>. \u0418\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e <code>get<\/code> \u0438 <code>set<\/code> \u0434\u043b\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u0442\u043e \u0435\u0441\u0442\u044c:<\/p>\n<pre><code class=\"cs\">public class MyClass {   private EventHandler myEvent;   public event EventHandler MyEvent   {     add { myEvent += value; }     remove { myEvent -= value; }   } } <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrahabr.zeegin.com\/topic172329\/3.bmp\" alt=\"image\"\/>  <\/p>\n<pre><code class=\"cs\">int i = 5; object o = i; long j = (long)o; <\/code><\/pre>\n<p>  <i>\u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 <u>\u043d\u0435 \u0437\u043d\u0430\u0435\u0442<\/u> \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441.<\/i><\/p>\n<p>  \u0411\u0443\u0434\u0435\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <i><b>InvalidCastException<\/b><\/i> (\u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e\u043c \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u0438\u043b\u0438 \u044f\u0432\u043d\u043e\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0438\u043f\u043e\u0432). \u041e\u0448\u0438\u0431\u043a\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0435. <\/p>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u2014 \u044d\u0442\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u0431\u044b\u0432\u0430\u0435\u0442 \u044f\u0432\u043d\u044b\u043c (explicit) \u0438 \u043d\u0435\u044f\u0432\u043d\u044b\u043c (implicit):  <\/p>\n<pre><code class=\"cs\">int i = 123; long l = (long)i;  \/\/ explicit   int i = 123; long l = i;  \/\/ implicit  <\/code><\/pre>\n<p>  \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0434\u0432\u0430 \u0432\u0438\u0434\u0430 \u0442\u0438\u043f\u043e\u0432: value-type \u0438 reference-type (\u0442\u0438\u043f\u044b-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u0442\u0438\u043f\u044b-\u0441\u0441\u044b\u043b\u043a\u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e), \u0432 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0441 \u0441\u0441\u044b\u043b\u043e\u0447\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 <code>boxing<\/code> (\u0443\u043f\u0430\u043a\u043e\u0432\u043a\u0430) \u044d\u0442\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.  <\/p>\n<blockquote><p>Boxing is the process of converting a value type to the type object or to any interface type implemented by this value type<\/p><\/blockquote>\n<p>  \u041e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>unboxing<\/code> (\u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u043a\u0430).<\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0440\u0435\u0442\u044c\u044e \u0441\u0442\u0440\u043e\u0447\u043a\u0443 <code>long j = (int)o<\/code>; \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d <code>unboxing<\/code> \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0442\u0438\u043f\u0430 <code>int<\/code>, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 <code>implicit<\/code> \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrahabr.zeegin.com\/topic172329\/4.bmp\" alt=\"image\"\/><\/p>\n<p>  \u0412\u0441\u0435, <b><i>\u043a\u0440\u043e\u043c\u0435<\/i><\/b> \u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u044b <i><b>#typedef<\/b><\/i>.<\/p>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>#define<\/code> \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0430\u043a\u0440\u043e\u0441\u044b, \u043a\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0421++, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0414\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430\u043c\u0438 <code>#if<\/code>, <code>#else<\/code>, <code>#endif<\/code> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0410\u0442\u0440\u0438\u0431\u0443\u0442 <code>Conditional<\/code> \u0441\u043b\u0443\u0436\u0438\u0442 \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u043d\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u043b\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>#define<\/code>.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Conditional<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">#define TRACE_ON using System; using System.Diagnostics;  public class Trace {     [Conditional(&quot;TRACE_ON&quot;)]     public static void Message(string msg)     {         Console.WriteLine(msg);     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrahabr.zeegin.com\/topic172329\/5.bmp\" alt=\"image\"\/><\/p>\n<p>  \u0412 C# \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0435\u043d \u043c\u043e\u0436\u043d\u043e \u043b\u0438\u0431\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0432 \u0438\u0445 \u0438\u043c\u0435\u043d\u0430 <i><b>\u0447\u0435\u0440\u0435\u0437 \u0442\u043e\u0447\u043a\u0443, \u043b\u0438\u0431\u043e \u0432\u043b\u043e\u0436\u0438\u0432 \u043e\u0434\u043d\u043e \u0432 \u0434\u0440\u0443\u0433\u043e\u0435<\/b><\/i> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <code>{ }<\/code>.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrahabr.zeegin.com\/topic172329\/6.bmp\" alt=\"image\"\/><\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>unsafe<\/code> \u043a\u043e\u0434 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e <i><b>\u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441 \u043a\u043b\u044e\u0447\u043e\u043c \/unsafe<\/b><\/i>, \u044d\u0442\u043e\u0442 \u043a\u043b\u044e\u0447 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0441 <code>unsafe<\/code> \u043a\u043e\u0434\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e <i><b>\u043f\u043e\u043c\u0435\u0442\u0438\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c unsafe<\/b><\/i>.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrahabr.zeegin.com\/topic172329\/7.bmp\" alt=\"image\"\/><\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043a\u043d\u043e\u043f\u043a\u043e\u0439. \u0421\u043e\u0437\u0434\u0430\u0432 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Button<\/code>, \u043c\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u0435\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 <code>Click<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043e\u0431\u044a\u0435\u043a\u0442 <code>Button<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u043c (<b><i>publisher<\/i><\/b>), \u0430 \u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u0434\u043f\u0438\u0441\u0447\u0438\u043a\u043e\u043c (<b><i>subscriber<\/i><\/b>).<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrahabr.zeegin.com\/topic172329\/8.bmp\" alt=\"image\"\/><\/p>\n<p>  \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u043c\u0435\u0441\u0442\u0430 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrahabr.zeegin.com\/topic172329\/9.bmp\" alt=\"image\"\/><br \/>  <i>\u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 <u>\u043d\u0435 \u0437\u043d\u0430\u0435\u0442<\/u> \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441.<\/i><\/p>\n<p>  <i><b>\u0412\u0441\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b<\/b><\/i> \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0442\u0438\u043f\u0435-\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 <code>AttributeTargets<\/code>, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435 <code>AttributeUsage<\/code>, \u0441\u043b\u0443\u0436\u0430\u0449\u0435\u0433\u043e \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430, \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u043a \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e:  <\/p>\n<pre><code class=\"cs\">using System.Runtime.InteropServices;  [DllImport(&quot;user32.dll&quot;, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern Boolean MessageBeep(UInt32 uType); <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrahabr.zeegin.com\/topic172329\/10.bmp\" alt=\"image\"\/><\/p>\n<p>  \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e <b><i>System.Runtime.InteropServices<\/i><\/b>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u043c \u043a\u043e\u0434\u043e\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0445\u043e\u0440\u043e\u0448\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>DllImport<\/code>, \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f DLL-\u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrahabr.zeegin.com\/topic172329\/11.bmp\" alt=\"image\"\/><br \/>  <i>\u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 <u>\u043d\u0435 \u0437\u043d\u0430\u0435\u0442<\/u> \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441.<\/i><\/p>\n<p>  \u0410\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c <code>Obsolete<\/code> \u043e\u0442\u043c\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c\u0430\u044f \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041a\u0430\u0436\u0434\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u043d\u043e\u0439 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0435\u0439, \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043a \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u044d\u0442\u043e\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430.<\/p>\n<p>  <a href=\"http:\/\/msdn.microsoft.com\/ru-ru\/library\/22kk2b44(v=vs.90).aspx\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043d\u0430 MSDN<\/a><\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrahabr.zeegin.com\/topic172329\/12.bmp\" alt=\"image\"\/><\/p>\n<p>  \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u043d\u043e \u043c\u043e\u0433\u0443\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b. \u0422\u0430\u043a\u0436\u0435 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u041d\u043e, \u043e\u0434\u043d\u0430\u043a\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430.    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/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=\"http:\/\/habrahabr.ru\/post\/172329\/\"> http:\/\/habrahabr.ru\/post\/172329\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041d\u0430 \u043c\u0438\u043d\u0443\u0432\u0448\u0438\u0445 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u044f \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b \u043f\u043e\u0441\u0442 <a href=\"http:\/\/habrahabr.ru\/post\/135563\/\"><b>\u00ab\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e .NET \u0438 C#\u00bb<\/b><\/a><\/p>\n<p>  \u042f \u0434\u0443\u043c\u0430\u044e \u043c\u043d\u043e\u0433\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u043e\u0442\u0432\u0435\u0442\u044b, \u043d\u043e \u0438 \u0443\u0437\u043d\u0430\u0442\u044c \u043a\u0430\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0437\u043d\u0430\u0435\u0442 \u044d\u0442\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u043e\u0442\u0432\u0435\u0442\u044b. \u0418\u043c\u0435\u043d\u043d\u043e \u0441 \u044d\u0442\u043e\u0439 \u0446\u0435\u043b\u044c\u044e \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0441\u044f \u044d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442.<\/p>\n<p>  \u042f \u043d\u0435 \u043d\u0430\u0441\u0442\u0430\u0438\u0432\u0430\u044e \u043d\u0430 \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0439 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u043a\u0440\u0438\u0442\u0438\u043a\u0430, \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0438 \u0443\u0442\u043e\u0447\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442\u0441\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrahabr.zeegin.com\/topic135563\/Csharp.png\" alt=\"image\"\/><\/p>\n<p>  \u041e\u0431\u0435\u0449\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u0432\u0435\u0442\u044b \u0441 \u0440\u0430\u0437\u0431\u043e\u0440\u043e\u043c \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c.<\/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-172329","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/172329","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=172329"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/172329\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=172329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=172329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=172329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}