{"id":384334,"date":"2024-06-29T05:26:48","date_gmt":"2024-06-29T05:26:48","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=384334"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-29T05:26:48","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=384334","title":{"rendered":"<span>\u041a\u0430\u043a \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 C# \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e: \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b54\/af5\/7b4\/b54af57b4563ec6dc57752c8920916f3.png\" width=\"1280\" height=\"720\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b54\/af5\/7b4\/b54af57b4563ec6dc57752c8920916f3.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a \u0441\u0442\u0430\u0440\u0442\u0443 \u043a\u0443\u0440\u0441\u0430 \u043e <a href=\"https:\/\/skillfactory.ru\/csharp?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_CDEV&amp;utm_term=regular&amp;utm_content=240721\">\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043d\u0430 C#<\/a> \u0434\u0435\u043b\u0438\u043c\u0441\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u0441\u0442\u0430\u0442\u044c\u0438 \u043e \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 C# \u043e\u0442 \u041a\u0440\u0438\u0441\u0442\u043e\u0444\u0430 \u041d\u0430\u0441\u0430\u0440\u0440\u0435 \u2014 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0440\u0435\u0446\u0435\u043d\u0437\u0435\u043d\u0442\u0430 \u043a\u043d\u0438\u0433 Microsoft Press \u0432 \u0446\u0435\u043b\u043e\u043c \u0438, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043a\u043d\u0438\u0433\u0438 CLR via C# \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u041a\u0440\u0438\u0441\u0442\u043e\u0444 \u041d\u0430\u0441\u0430\u0440\u0440\u0435 \u2014 \u043e\u0434\u0438\u043d \u0438\u0437 \u0430\u0432\u0442\u043e\u0440\u043e\u0432 \u043a\u043d\u0438\u0433\u0438 Windows via C++.<\/p>\n<hr\/>\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043d\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 \u043c\u0443\u0441\u043e\u0440\u0430 (\u0434\u0430\u043b\u0435\u0435 \u2014 GC \u2014 Garbage Collector), \u043d\u043e, \u0447\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0442\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 GC \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0446\u0435\u043b\u044c \u2014 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0432\u044b\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043a\u043e\u0434\u0430 \u0438\u043b\u0438 \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u0438\u0445 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0434\u043e\u043b\u0433\u043e. \u041f\u043e\u043c\u043e\u0433\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c Criteo \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u0434, \u044f \u0441\u043e\u0431\u0440\u0430\u043b \u0438 \u0437\u0430\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u043d\u0442\u0438\u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 C#, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430\u043c \u0438\u0437 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 <a href=\"https:\/\/twitter.com\/KooKiz\">\u041a\u0435\u0432\u0438\u043d\u0430<\/a> \u043e <a href=\"https:\/\/kevingosse.medium.com\/performance-best-practices-in-c-b85a47bdd93a\">\u043a\u043e\u0434\u0435 \u0441 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u043c \u0437\u0430\u043f\u0430\u0445\u043e\u043c<\/a>. \u0412\u043e\u0442 \u0432\u044b\u0434\u0435\u0440\u0436\u043a\u0430 \u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u0438 \u043f\u043b\u043e\u0445\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u044f\u0445 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<h2>\u0424\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438 IDisposable<\/h2>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441\u043e \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u00ab\u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430\u00bb \u2014 \u0441\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442. \u041f\u0438\u0448\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434, \u0438\u043c\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u2014 \u044d\u0442\u043e \u0438\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0441 \u043f\u0440\u0435\u0301\u0444\u0438\u043a\u0441\u043e\u043c <code>~<\/code>. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.object.finalize?WT.mc_id=DT-MVP-5003325\">Object.Finalize<\/a>, \u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0442\u0438\u043f\u0430 \u0441 \u0442\u0430\u043a\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f GC \u043e\u0441\u043e\u0431\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438 \u0441\u0441\u044b\u043b\u043a\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 <code>Finalization<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430 <code>Finalization<\/code> \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f, \u044d\u0442\u0430 \u0441\u0441\u044b\u043b\u043a\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u2014 <code>fReachable<\/code> \u2014 \u0438 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043a\u043e\u0440\u043d\u0435\u0432\u0430\u044f, \u043f\u043e\u043a\u0430 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u043d\u0435 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u043a\u043e\u0434 \u0435\u0451 \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u043e\u043d\u0440\u0430\u0434 \u041a\u043e\u043a\u043e\u0441\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0441\u0432\u043e\u0438\u0445 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0445<a href=\"https:\/\/twitter.com\/konradkokosa\"> \u0432\u0438\u0434\u0435\u043e <\/a>\u043e GC \u0438\u0437\u043d\u0443\u0442\u0440\u0438 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u0442\u0438\u043f\u0430, \u0433\u0434\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440, \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e, \u043e\u0436\u0438\u0434\u0430\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0431\u043e\u0440\u043a\u0438 \u043c\u0443\u0441\u043e\u0440\u0430 \u043f\u043e\u043a\u043e\u043b\u0435\u043d\u0438\u044f, \u0433\u0434\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0430\u044f \u0441\u0431\u043e\u0440\u043a\u0430 \u043c\u0443\u0441\u043e\u0440\u0430, \u0442. \u0435. <code>gen1<\/code>, \u0435\u0441\u043b\u0438 \u043e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0441\u044f \u0432 <code>gen0<\/code>, \u0438\u043b\u0438 <code>gen2<\/code>, \u0435\u0441\u043b\u0438 \u0432 <code>gen1<\/code>, \u0447\u0442\u043e \u0435\u0449\u0451 \u0445\u0443\u0436\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u0447\u0430\u0441\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u0433\u043e, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440. \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043e\u0442\u0432\u0435\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c. \u0424\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0447\u0438\u0449\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u043e\u0442 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 <code>COM<\/code> \u0438\u043b\u0438 <code>P\/Invoke<\/code> \u00ab\u043d\u0435\u0447\u0442\u043e\u00bb: \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u044b, \u043d\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u0438\u043b\u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.runtime.interopservices.marshal?WT.mc_id=DT-MVP-5003325\">Marshal<\/a>-\u0445\u0435\u043b\u043f\u0435\u0440\u044b \u043f\u0430\u043c\u044f\u0442\u044c. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u044f <code>IntPtr<\/code>, \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0437\u043d\u0430\u043a \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0438\u0445 \u0436\u0438\u0437\u043d\u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0435 \u0447\u0435\u0440\u0435\u0437 \u0445\u0435\u043b\u043f\u0435\u0440\u044b Marshal \u0438\u043b\u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 <code>P\/Invoke<\/code>. \u0418\u0449\u0438\u0442\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0442 <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.runtime.interopservices.safehandle?WT.mc_id=DT-MVP-5003325\">SafeHandle<\/a> \u043a\u043b\u0430\u0441\u0441, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u044f\u0434\u0440\u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 IntPtr, \u0438\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u0432. \u0418\u0442\u0430\u043a, \u0432 99,9% \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d.<\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441: \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.idisposable?WT.mc_id=DT-MVP-5003325\">IDisposable<\/a>? \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 <code>Dispose()<\/code> \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 <code>IDisposable<\/code> \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 \u043c\u0443\u0441\u043e\u0440\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442, \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u043d\u0435 \u043f\u0440\u043e\u0434\u043b\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0438\u043a\u0430\u043a\u0438\u043c \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u043c \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u043c. <code>Dispose<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0435 \u0436\u0434\u0430\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0443 \u043c\u0443\u0441\u043e\u0440\u0430, \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044f\u0432\u043d\u043e \u043e\u0447\u0438\u0441\u0442\u0438\u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u043e\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430. <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440: \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0444\u0430\u0439\u043b \u0437\u0430 \u043a\u0443\u043b\u0438\u0441\u0430\u043c\u0438 .NET \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 API, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u0444\u0430\u0439\u043b\u043e\u043c \u0447\u0435\u0440\u0435\u0437 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u044f\u0434\u0440\u0430 \u0432 Windows \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u043c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c: \u0434\u0432\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043d\u0435 \u043f\u043e\u0432\u0440\u0435\u0434\u044f\u0442 \u0444\u0430\u0439\u043b \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0440\u0430\u0437\u043d\u044b\u0445 \u0431\u0430\u0439\u0442\u043e\u0432. \u042d\u0442\u043e \u0432\u0437\u0433\u043b\u044f\u0434 \u043d\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u0441 \u0432\u044b\u0441\u043e\u0442\u044b \u043f\u0442\u0438\u0447\u044c\u0435\u0433\u043e \u043f\u043e\u043b\u0451\u0442\u0430, \u043e\u0434\u043d\u0430\u043a\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0438 \u043e\u043d \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c. <\/p>\n<p>\u0414\u0440\u0443\u0433\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u0430\u0437\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439, \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0442\u044c \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u0440\u0435\u0435. \u0412\u043e \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445 \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u044d\u0442\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u00ab\u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0442\u044c\u00bb \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0437\u0430 \u043a\u0443\u043b\u0438\u0441\u0430\u043c\u0438 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435. \u042d\u0442\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0445\u043e\u0440\u043e\u0448\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d <code>using<\/code>:<\/p>\n<pre><code class=\"cs\">using (var disposableInstance = new MyDisposable()) {    DoSomething(disposableInstance); }; \/\/ the instance will be cleanup and its resources released<\/code><\/pre>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u043a\u043e\u0434 \u0432\u044b\u0448\u0435 \u0432 \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code class=\"cs\">var disposableInstance = new MyDisposable(); try {    DoSomething(disposableInstance); } finally {    disposableInstance?.Dispose(); }<\/code><\/pre>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u0435\u043d <code>IDisposable<\/code>? \u041c\u043e\u0439 \u043e\u0442\u0432\u0435\u0442 \u043f\u0440\u043e\u0441\u0442: \u043e\u043d \u043d\u0443\u0436\u0435\u043d, \u043a\u043e\u0433\u0434\u0430 \u043a\u043b\u0430\u0441\u0441 \u0432\u043b\u0430\u0434\u0435\u0435\u0442 \u043f\u043e\u043b\u044f\u043c\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0445 <code>IDisposable<\/code> \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u0435\u0441\u043b\u0438 \u043e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 (\u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u043b\u0430\u0441\u044c \u0432\u044b\u0448\u0435). \u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>IDisposable.Dispose<\/code> \u043f\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438, \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u043b\u043e\u0441\u044c \u0432 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 C++. \u041f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u044f\u0432\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441.<\/p>\n<p>\u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u044f \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u043f\u043e\u0447\u0435\u043c\u0443 \u043a\u043e\u0434 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Microsoft \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0439. \u0427\u0442\u043e\u0431\u044b \u00ab\u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c\u00bb \u043d\u0435\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0438\u043b\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u043d\u0438\u0436\u0435. \u0412\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u043a\u0430\u043a \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c, \u0442\u0430\u043a \u0438 <code>IDisposable.Dispose()<\/code>:<\/p>\n<pre><code class=\"cs\">var disposableInstance = new MyDisposable(); try {    DoSomething(disposableInstance); } finally {    disposableInstance?.Dispose(); }<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>IDisposable.Dispose()<\/code> \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0435 <code>_disposed<\/code>. \u0415\u0441\u043b\u0438 <code>_disposed<\/code> \u0440\u0430\u0432\u043d\u043e <code>true<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0439\u043c\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u0442\u0438\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0432\u043e \u0432\u0441\u0435\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445 \u043a\u043b\u0430\u0441\u0441\u0430 \u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <code>ObjectDisposedException<\/code>.<\/p>\n<p>\u0421\u043f\u0440\u043e\u0441\u0438\u0442\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u043a\u043e\u0433\u0434\u0430 <code>disposing<\/code> \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c <code>true<\/code> \u0438\u043b\u0438 <code>false<\/code>: \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u044f \u0441\u043e\u043c\u043d\u0435\u0432\u0430\u044e\u0449\u0438\u0445\u0441\u044f, \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u0441\u043a\u0430\u0436\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0438\u0437 \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430, \u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u2014 \u0438\u0437 <code>Dispose<\/code>.  \u0417\u0430\u0447\u0435\u043c \u0434\u0430\u0432\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0435 \u0438\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0432 <code>IDisposable<\/code>? \u041f\u043e\u0447\u0435\u043c\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>disposing<\/code>? \u042f \u0434\u0443\u043c\u0430\u044e, \u0438\u0437\u0431\u044b\u0442\u043e\u043a <code>Dispose<\/code> \u0443\u0431\u0438\u0432\u0430\u0435\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0449\u0435. \u0412\u043e\u0442 \u043c\u043e\u044f \u0432\u0435\u0440\u0441\u0438\u044f:<\/p>\n<pre><code class=\"cs\">class DisposableMe : IDisposable {     private bool _disposed = false;      \/\/ 1. field that implements IDisposable     \/\/ 2. field that stores \"native resource\" (ex: IntPtr)      ~DisposableMe()     {         Cleanup(\"called from GC\" != null);     }           \/\/ = true      public void Dispose()     {         Cleanup(\"not from GC\" == null);     }           \/\/ = false          ... }<\/code><\/pre>\n<p>\u042f \u0442\u0430\u043a\u0436\u0435 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043b <code>Dispose(bool disposing)<\/code> \u0432 <code>Cleanup(bool fromGC)<\/code>:<\/p>\n<pre><code class=\"cs\"> private void Cleanup(bool fromGC)  {      if (_disposed)          return;       try      {          \/\/ always clean up the NATIVE resources          if (fromGC)              return;           \/\/ clean up managed resources ONLY if not called from GC      }      finally      {          _disposed = true;           if (!fromGC)              GC.SuppressFinalize(this);      }  }<\/code><\/pre>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u043e\u0441\u0442\u044b. \u0417\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u0435 \u0438\u0445:<\/p>\n<ul>\n<li>\n<p>\u041d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u0442. \u0435. \u043f\u043e\u043b\u044f <code>IntPtr<\/code>, \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0447\u0438\u0449\u0430\u0442\u044c\u0441\u044f \u0432\u0441\u0435\u0433\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0423\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u0442. \u0435. \u043f\u043e\u043b\u044f <code>IDisposable<\/code>, \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0442\u0438\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0438\u0437 <code>Dispose<\/code>, \u043d\u043e \u043d\u0435 \u0438\u0437 GC.<\/p>\n<\/li>\n<\/ul>\n<p>\u041b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u043e\u043b\u0435 <code>_disposed<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437. \u0417\u0434\u0435\u0441\u044c \u043e\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0432 <code>true<\/code>, \u0434\u0430\u0436\u0435 \u043a\u043e\u0433\u0434\u0430 \u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, \u043e\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u0438 \u043f\u043e\u0437\u0434\u043d\u0435\u0435. \u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0432\u0430\u0436\u043d\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u044c: \u0432\u044b\u0437\u043e\u0432 <code>GC.SuppressFinalize(this)<\/code> \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 GC, \u0447\u0442\u043e \u0435\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0443\u0442\u0438\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0437  <code>Finalization<\/code>:<\/p>\n<ul>\n<li>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437 <code>Dispose<\/code> (\u043d\u0435 \u0438\u0437 GC), \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u043e\u0434\u043b\u0435\u0432\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p>\u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0438\u043d\u0430\u0447\u0435 \u043e\u043d \u0432\u044b\u0437\u043e\u0432\u0435\u0442 Cleanup, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u0442 \u043a \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0443, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <code>_disposed<\/code> \u0438\u0441\u0442\u0438\u043d\u043d\u043e.<\/p>\n<\/li>\n<\/ul>\n<p>\u0420\u0435\u0447\u044c \u0438\u0434\u0451\u0442 \u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u0434 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043e, \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u044b\u043c. \u0412\u0441\u0435\u0433\u0434\u0430 \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u0443\u0439\u0442\u0435 \u043c\u0435\u0436\u0434\u0443 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e, \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u043e\u0439 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u044f, \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430.<\/p>\n<h2>\u0414\u0430\u0439\u0442\u0435 \u0441\u043f\u0438\u0441\u043a\u0443 \u0437\u0430\u043f\u0430\u0441 \u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e<\/h2>\n<p>\u0421\u043e\u0437\u0434\u0430\u0432\u0430\u044f <code>List<\/code> \u0438\u043b\u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438, \u0434\u0430\u0439\u0442\u0435 \u0435\u043c\u0443 \u0437\u0430\u043f\u0430\u0441 \u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u0432 .NET \u043e\u0431\u044b\u0447\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435, \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432; \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e:<\/p>\n<ol>\n<li>\n<p>\u0412\u044b\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432. <\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0435\u0436\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043f\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u043d\u0435\u0433\u043e.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u043f\u0440\u0435\u0436\u043d\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f.<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cs\">var resultList = new List&lt;...>(); foreach (var item in otherList) {     resultList.Add(...); }<\/code><\/pre>\n<h2>StringBuilder \u043b\u0443\u0447\u0448\u0435 +\/+=<\/h2>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u0440\u0435\u0301\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0431\u043e\u0440\u043e\u043a \u043c\u0443\u0441\u043e\u0440\u0430 \u0438 \u0441\u043d\u0438\u0437\u0438\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041a\u043b\u0430\u0441\u0441 <code>string<\/code> \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u0435\u043d, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u0430 \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, .NET Framework \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043d\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<p>\u041f\u0440\u0438 \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u043e\u043a \u0438\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 <code>Concat<\/code>, <code>+<\/code> \u0438 <code>+=<\/code>. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u043e \u044d\u0442\u043e \u0434\u043b\u044f \u0446\u0438\u043a\u043b\u043e\u0432 \u0438 \u0447\u0430\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0412 \u043a\u043e\u0434\u0435 \u043d\u0438\u0436\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435 <code>StringBuilder<\/code>:<\/p>\n<pre><code class=\"cs\">var productIds = string.Empty; while (match.Success) {    productIds += match.Groups[2].Value + \"\\n\";    match = match.NextMatch(); }<\/code><\/pre>\n<p>\u0412 \u0446\u0438\u043a\u043b\u0430\u0445 \u0441\u0442\u0430\u0440\u0430\u0439\u0442\u0435\u0441\u044c \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a. \u041d\u0438\u0436\u0435 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f <code>SearchValue.ToUpper()<\/code>:<\/p>\n<pre><code class=\"cs\">if (SelectedColumn == Resources.Journaux.All &amp;&amp; !String.IsNullOrEmpty(SearchValue))     source = model.DataSource.Where(x => x.ItemId.Contains(SearchValue)         || x.ItemName.ToUpper().Contains(SearchValue.ToUpper())         || x.ItemGroupName.ToUpper().Contains(SearchValue.ToUpper())         || x.CountingGroupName.ToUpper().Contains(SearchValue.ToUpper()));     if (SelectedColumn == Resources.Journaux.ItemNumber)     source = model.DataSource.Where(x => x.ItemId.ToUpper().Contains(SearchValue.ToUpper()));     if (SelectedColumn == Resources.Journaux.ItemName)     source = model.DataSource.Where(x => x.ItemName.ToUpper().Contains(SearchValue.ToUpper()));     if (SelectedColumn == Resources.Journaux.ItemGroup)     source = model.DataSource.Where(x => x.ItemGroupName.ToUpper().Contains(SearchValue.ToUpper()));   if (SelectedColumn == Resources.Journaux.CountingGroup)     source = model.DataSource.Where(x => x.CountingGroupName.ToUpper().Contains(SearchValue.ToUpper()));<\/code><\/pre>\n<p>\u042d\u0444\u0444\u0435\u043a\u0442 \u0443\u0441\u0443\u0433\u0443\u0431\u043b\u044f\u0435\u0442\u0441\u044f <code>Where()<\/code>, \u0433\u0434\u0435 \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438! \u042d\u0442\u043e \u0432\u0435\u0440\u043d\u043e \u0438 \u0434\u043b\u044f \u0442\u0438\u043f\u043e\u0432, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445 \u0434\u043e\u0441\u0442\u0443\u043f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<pre><code>if (!uriBuilder.ToString().EndsWith(\".\", true, invCulture))<\/code><\/pre>\n<p><code>ToString()<\/code> \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e:<\/p>\n<pre><code class=\"cs\">if (uriBuilder[uriBuilder.Length - 1] != '.')<\/code><\/pre>\n<h2>\u0418\u043d\u0442\u0435\u0440\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a<\/h2>\n<p>\u041b\u0443\u0447\u0448\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f, \u0430 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435:<\/p>\n<pre><code>var allCampaignStatuses =     ((CampaignActivityStatus[])Enum.GetValues(typeof(CampaignActivityStatus)))    .ToList();<\/code><\/pre>\n<p>\u042d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c.<\/p>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u043d\u043e \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0432\u0430\u0436\u043d\u043e\u0435: \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c CLR \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0441\u0441\u044b\u043b\u043a\u0443. \u042d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0438\u043d\u0442\u0435\u0440\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0432 <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.string.intern\">Microsoft Docs<\/a>.<\/p>\n<h2>\u041d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0434\u0438 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0431\u0435\u0437 \u043f\u043e\u043b\u0435\u0439, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435\u0441\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0441\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438. \u0422\u0430\u043a\u0436\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f, \u0430 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e  \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"cs\">var allCampaignStatuses =     ((CampaignActivityStatus[])Enum.GetValues(typeof(CampaignActivityStatus)))    .ToList();    \/\/ use allCampaignStatuses in the rest of the method<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0435\u0434\u0438\u043d\u043e\u0436\u0434\u044b \u043a\u0430\u043a \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u043e\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>\u0412 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0446\u0438\u043a\u043b\u043e\u043c \u0438\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0439\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445; \u043e\u0431 \u044d\u0442\u043e\u043c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0437\u0430\u0431\u044b\u0442\u044c, \u0438\u043c\u0435\u044f \u0434\u0435\u043b\u043e \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0441\u0442\u0440\u043e\u043a <code>ToLower()<\/code> \u0438 <code>ToUpper()<\/code>. \u041d\u043e\u0432\u0430\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0432 <code>key.ToLower()<\/code> \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439:<\/p>\n<pre><code class=\"cs\">var found = elements.Any( \/\/ ToLower() is called in each test k => string.Compare(        k.ToLower(),         key.ToLower(),         StringComparison.OrdinalIgnoreCase        ) == 0);<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u0430 <code>ToLower()<\/code> \u0438\u043b\u0438 <code>ToUpper()<\/code> \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0434\u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a, \u043a\u0430\u043a \u043d\u0438\u0436\u0435, \u0440\u0430\u0431\u043e\u0442\u0430\u0439\u0442\u0435 \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>String.Compare (...,... StringComparison.OrdinalIgnoreCase)<\/code>. \u042d\u0442\u043e\u0442 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cs\">if (transactionIdAsString != null &amp;&amp; transactionIdAsString.ToLowerInvariant() == \"undefined\")<\/code><\/pre>\n<p>\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code class=\"cs\">if (transactionIdAsString != null &amp;&amp; string.Compare(transactionIdAsString, \"undefined\", StringComparison.OrdinalIgnoreCase) == 0)<\/code><\/pre>\n<h2>\u041b\u0443\u0447\u0448\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 LINQ<\/h2>\n<p>LINQ \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432\u0435\u0437\u0434\u0435, \u0441\u043d\u0438\u0436\u0430\u044e\u0449\u0438\u0435 \u043e\u0431\u0449\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0435\u0442\u0430\u043b\u0438 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e.<\/p>\n<h2>\u041f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0439\u0442\u0435 IEnumerable IList<\/h2>\n<p>\u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u044e\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 <code>IEnumerable<\/code> \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 <code>foreach()<\/code> \u0438\u043b\u0438 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043c\u0435\u0442\u043e\u0434\u0430\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f <code>System.Linq.Enumerable<\/code>. \u0421 <code>IList<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0439\u0442\u0435, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/11f\/983\/633\/11f983633170a36993fb0c88338b36b7.png\" width=\"501\" height=\"286\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/11f\/983\/633\/11f983633170a36993fb0c88338b36b7.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438 \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u044e\u0442\u0441\u044f, \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043c\u0435\u0442\u043e\u0434\u0430 \u0432\u043c\u0435\u0441\u0442\u043e <code>IList<\/code> \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435\u0441\u044c <code>IEnumerable<\/code>: \u0442\u043e\u0433\u0434\u0430 \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0432 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u043c \u043a\u043e\u0434\u0435 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d <code>ToList()<\/code>. \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f <code>foreach<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d\u0438 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0442\u0438\u043f <code>IEnumerable<\/code>, \u043d\u043e \u043d\u0435 <code>IList<\/code>.<\/p>\n<h2>FirstOrDefault \u0438 Any \u043c\u043e\u0433\u0443\u0442 \u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f<\/h2>\n<p>\u041d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0434 <code>foreach<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>Any<\/code> \u0438\u043b\u0438, \u0435\u0449\u0451 \u0445\u0443\u0436\u0435, <code>ToList().Count > 0<\/code>, \u043a\u0430\u043a \u043d\u0438\u0436\u0435:<\/p>\n<pre><code>if (sequence != null &amp;&amp; sequence.Any()) {    foreach (var item in sequence)    ... }<\/code><\/pre>\n<h2>\u0418\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u0445 ToList() \u0438 ToArray()<\/h2>\n<p>\u041f\u043e\u043a\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0442\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430 , \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0447\u0435\u0440\u0435\u0437 foreach, \u0437\u0430\u043f\u0440\u043e\u0441\u044b LINQ \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435. \u0422\u043e \u0436\u0435 \u0432\u0435\u0440\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430 \u0442\u0430\u043a\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f <code>ToList()<\/code> \u0438\u043b\u0438 <code>ToArray()<\/code>:<\/p>\n<pre><code class=\"cs\">var resourceNames = resourceAssembly .GetManifestResourceNames() .Where(r => r.StartsWith($\"{resourcePath}.i18n\")) .ToArray();  foreach (var resourceName in resourceNames) {    ... }<\/code><\/pre>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>ToList()<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <code>List&lt;><\/code> \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0418\u0437-\u0437\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 <code>List&lt;><\/code> \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u0437 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0432 \u0441\u043c\u044b\u0441\u043b\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>ToList()<\/code> \u0441 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e. \u0412\u043e\u0442 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f:<\/p>\n<ol>\n<li>\n<p>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0435\u0441\u043b\u0438 \u043e\u043d \u0434\u043e\u0440\u043e\u0433.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u043f\u043e\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430. <\/p>\n<\/li>\n<\/ol>\n<p>\u0427\u0430\u0441\u0442\u043e \u043f\u0440\u0438 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e <code>IEnumerable<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>ToList()<\/code> \u043d\u0435 \u043d\u0443\u0436\u043d\u043e: \u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u0438\u0437-\u0437\u0430 \u043d\u0435\u043d\u0443\u0436\u043d\u043e\u0433\u043e <code>ListenAddress<\/code> \u0432\u044b \u043d\u0430\u0432\u0440\u0435\u0434\u0438\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438, \u043d\u043e \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e; \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u0438\u0442\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0432\u0430\u0436\u0434\u044b, \u0447\u0442\u043e \u0441\u043d\u0438\u0437\u0438\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u0430 <code>LINQ to Object<\/code> \u2014 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>IEnumerable<\/code> \u0434\u043b\u044f \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0412\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f LINQ \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b <code>IEnumerable<\/code> \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c <code>foreach<\/code>. \u0422\u0430\u043a\u0436\u0435 <code>ToList()<\/code> \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u043a\u043e\u0433\u0434\u0430 \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f <code>IEnumerable<\/code>. \u0412 \u044d\u0442\u043e\u043c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u043e\u0439\u043d\u0430\u044f \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0435\u0441\u0442\u044c <code>IEnumerable IList\/List\/[]<\/code> \u0432 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432.<\/p>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 <code>ToList()<\/code> \u043f\u0435\u0440\u0435\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c <code>Where<\/code> \u043a <code>IEnumerable<\/code>. \u042d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c <code>Where<\/code> \u0446\u0435\u043f\u043e\u0447\u043a\u043e\u0439 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>ToList()<\/code> \u0432 \u043a\u043e\u043d\u0446\u0435.<\/p>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443: \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>ToList()<\/code>, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c \u0434\u043b\u0438\u043d\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">productInfos   .Select(p => p.Split(DisplayProductInfoSeparator)[0])   .Distinct()   .ToList()   .Count;<\/code><\/pre>\n<p>\u042d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cs\">productInfos   .Select(p => p.Split(DisplayProductInfoSeparator)[0])   .Distinct()   .Count();<\/code><\/pre>\n<h3>IEnumerable&lt;>.Any \u043b\u0443\u0447\u0448\u0435 List&lt;>.Exists<\/h3>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 <code>IEnumerable<\/code> \u0432\u043c\u0435\u0441\u0442\u043e <code>ToList().Exists()<\/code> \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f <code>Any<\/code>:<\/p>\n<pre><code class=\"cs\">if (sequence.ToList().Exists(\u2026))<\/code><\/pre>\n<p>\u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cs\">if (sequence.Any(...))<\/code><\/pre>\n<h3>\u0412 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0443\u0441\u0442, Any \u043b\u0443\u0447\u0448\u0435 Count<\/h3>\n<p>\u041c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f <code>Any<\/code> \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0435\u0441\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u043c \u043d\u0430 <code>IEnumerable<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 (\u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u0435\u0441\u0442\u044c) \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e, \u0431\u0435\u0437 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430. \u042d\u0442\u043e\u0442 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cs\">var nonArchivedCampaigns =     campaigns    .Where(c => c.Status != CampaignActivityStatus.Archived)    .ToList(); if (nonArchivedCampaigns.Count == 0)<\/code><\/pre>\n<p>\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code class=\"cs\">if (!campaigns.Where(c => c.Status != CampaignActivityStatus.Archived).Any())<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435: \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>if (!campaigns.Any (filter))<\/code>.<\/p>\n<h2>\u041f\u043e\u0440\u044f\u0434\u043e\u043a \u0432 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0445 \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044f\u043c <code>IEnumerable<\/code> \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041e\u0434\u043d\u043e \u0438\u0437 \u0432\u0430\u0436\u043d\u044b\u0445 \u043f\u0440\u0430\u0432\u0438\u043b \u2014 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0434 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438\u0441\u044c \u0432\u0441\u0451 \u043c\u0435\u043d\u044c\u0448\u0435 \u0438 \u043c\u0435\u043d\u044c\u0448\u0435. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043f\u0440\u043e\u0441 LINQ \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u0441 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 <code>Where<\/code>. \u0412 LINQ \u043a\u043e\u0434 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0441\u043c\u044b\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0431\u043c\u0430\u043d\u0447\u0438\u0432\u044b\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0447\u0451\u043c \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443:<\/p>\n<pre><code class=\"cs\">var filteredElements = sequence   .Where(first filter)   .Where(second filter)   ;<\/code><\/pre>\n<p>\u0438:<\/p>\n<pre><code class=\"cs\">var filteredElements = sequence   .Where(first filter &amp;&amp; second filter)   ;<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 <code>LINQ for Objects<\/code>, \u043f\u043e\u0445\u043e\u0436\u0435, \u043f\u043e\u0441\u043b\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0432 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u044b: \u043e\u0431\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0440\u0430\u0437:<\/p>\n<pre><code class=\"cs\"> var integers = Enumerable.Range(1, 6);  var set1 = integers  .Where(i => IsEven(i))  .Where(i => IsMultipleOf3(i));   foreach (var current in set1)  {      Console.WriteLine($\"--> {current}\");  }   Console.WriteLine(\"--------------------------------\");   var set2 = integers  .Where(i => IsEven(i) &amp;&amp; IsMultipleOf3(i))  ;   foreach (var current in set1)  {      Console.WriteLine($\"--> {current}\");  }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0432 \u043a\u043e\u0434, \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<pre><code class=\"python\">IsEven(1) IsEven(2)    IsMultipleOf3(2) IsEven(3) IsEven(4)    IsMultipleOf3(4) IsEven(5) IsEven(6)    IsMultipleOf3(6) --> 6 -------------------------------- IsEven(1) IsEven(2)    IsMultipleOf3(2) IsEven(3) IsEven(4)    IsMultipleOf3(4) IsEven(5) IsEven(6)    IsMultipleOf3(6) --> 6<\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0434 Benchmark.NET \u0443 \u00ab\u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0451\u043d\u043d\u043e\u0433\u043e\u00bb \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f <code>Where<\/code> \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0443\u0447\u0448\u0435:<\/p>\n<pre><code class=\"cs\"> private int[] _myArray;   [Params(10, 1000, 10000)]  public int Size { get; set; }   [GlobalSetup]  public void Setup()  {      _myArray = new int[Size];       for (var i = 0; i &lt; Size; i++)          _myArray[i] = i;  }   [Benchmark(Baseline = true)]  public void Original()  {      var set = _myArray          .Where(i => IsEven(i))          .Where(i => IsMultipleOf3(i))          ;       int i;      foreach (var current in set)      {          i = current;      }  }   [Benchmark]  public void Merged()  {      var set = _myArray          .Where(i => IsEven(i) &amp;&amp; IsMultipleOf3(i))          ;       int i;      foreach (var current in set)      {          i = current;      }  }<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d4e\/363\/d5b\/d4e363d5bc22e3bfdba48aef7d2758c0.png\" width=\"700\" height=\"138\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d4e\/363\/d5b\/d4e363d5bc22e3bfdba48aef7d2758c0.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0418\u0437\u0443\u0447\u0438\u0432 <a href=\"https:\/\/referencesource.microsoft.com\/#System.Core\/System\/Linq\/Enumerable.cs,44b8532e11187695\">\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e<\/a> \u0432 .NET Framework \u0441 \u043c\u043e\u0438\u043c \u043a\u043e\u043b\u043b\u0435\u0433\u043e\u0439 \u0414\u0436\u0438\u043d\u043e\u043c-\u0424\u0438\u043b\u0438\u043f\u0435, \u043c\u044b \u0443\u0432\u0438\u0434\u0435\u043b\u0438, \u0447\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u044b, \u043f\u043e\u0445\u043e\u0436\u0435, \u0438\u043c\u0435\u044e\u0442 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u043e\u0432\u043e\u043c\u0443 <code>IEnumerator<\/code>, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u0441 \u043f\u0435\u0440\u0432\u044b\u043c <code>Where<\/code>, [\u043d\u043e] \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0439\u0442\u0435, \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0437\u043c\u0435\u0440\u044f\u0439\u0442\u0435.<\/p>\n<p>\u0418 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0435 \u043d\u0430 \u043d\u0430\u0448 \u043a\u0443\u0440\u0441 <a href=\"https:\/\/skillfactory.ru\/csharp?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_CDEV&amp;utm_term=regular&amp;utm_content=240721\">\u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043d\u0430 \u0421#<\/a>, \u0433\u0434\u0435 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u0439\u0442\u0438 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0432\u043b\u0430\u0434\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u043c \u044f\u0437\u044b\u043a\u043e\u043c \u0438\u043b\u0438 \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u0441 \u043d\u0443\u043b\u044f \u0438 \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 HR, \u0447\u0442\u043e\u0431\u044b \u0441\u0442\u0430\u0442\u044c Junior-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c. \u0422\u0430\u043a\u0436\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 <a href=\"https:\/\/skillfactory.ru\/courses\/?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_ALLCOURSES&amp;utm_term=regular&amp;utm_content=240721\">\u0443\u0437\u043d\u0430\u0442\u044c<\/a>, \u043a\u0430\u043a \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u0430\u0440\u044c\u0435\u0440\u0443 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u0445:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/99b\/c44\/5d1\/99bc445d1960fc06585354b01d45d2c9.png\" width=\"1000\" height=\"200\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/99b\/c44\/5d1\/99bc445d1960fc06585354b01d45d2c9.png\"\/><figcaption><\/figcaption><\/figure>\n<p><strong>Data Science \u0438 Machine Learning<\/strong><\/p>\n<ul>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/dstpro?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_DSPR&amp;utm_term=regular&amp;utm_content=240721\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Data Scientist<\/a><\/p>\n<\/li>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/dataanalystpro?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_DAPR&amp;utm_term=regular&amp;utm_content=240721\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Data Analyst<\/a><\/p>\n<\/li>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/math-stat-for-ds#syllabus?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_MAT&amp;utm_term=regular&amp;utm_content=240721\">\u041a\u0443\u0440\u0441 \u00ab\u041c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430 \u0434\u043b\u044f Data Science\u00bb<\/a><\/p>\n<\/li>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/math_and_ml?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_MATML&amp;utm_term=regular&amp;utm_content=240721\">\u041a\u0443\u0440\u0441 \u00ab\u041c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430 \u0438 Machine Learning \u0434\u043b\u044f Data Science\u00bb<\/a><\/p>\n<\/li>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/dataengineer?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_DEA&amp;utm_term=regular&amp;utm_content=240721\">\u041a\u0443\u0440\u0441 \u043f\u043e Data Engineering<\/a><\/p>\n<\/li>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/ml-and-dl?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_MLDL&amp;utm_term=regular&amp;utm_content=240721\">\u041a\u0443\u0440\u0441 \u00abMachine Learning \u0438 Deep Learning\u00bb<\/a><\/p>\n<\/li>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/ml-programma-machine-learning-online?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_ML&amp;utm_term=regular&amp;utm_content=240721\">\u041a\u0443\u0440\u0441 \u043f\u043e Machine Learning<\/a><\/p>\n<\/li>\n<\/ul>\n<p><strong>Python, \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430<\/strong><\/p>\n<ul>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/python-fullstack-web-developer?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_FPW&amp;utm_term=regular&amp;utm_content=240721\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Fullstack-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 Python<\/a><\/p>\n<\/li>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/python-for-web-developers?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_PWS&amp;utm_term=regular&amp;utm_content=240721\">\u041a\u0443\u0440\u0441 \u00abPython \u0434\u043b\u044f \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438\u00bb<\/a><\/p>\n<\/li>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/frontend?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_FR&amp;utm_term=regular&amp;utm_content=240721\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Frontend-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/a><\/p>\n<\/li>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/webdev?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_WEBDEV&amp;utm_term=regular&amp;utm_content=240721\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f \u0412\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/a><\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041c\u043e\u0431\u0438\u043b\u044c\u043d\u0430\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430<\/strong><\/p>\n<ul>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/iosdev?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_IOSDEV&amp;utm_term=regular&amp;utm_content=240721\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f iOS-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/a><\/p>\n<\/li>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/android?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_ANDR&amp;utm_term=regular&amp;utm_content=240721\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Android-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/a><\/p>\n<\/li>\n<\/ul>\n<p><strong>Java \u0438 C#<\/strong><\/p>\n<ul>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/java?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_JAVA&amp;utm_term=regular&amp;utm_content=240721\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Java-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/a><\/p>\n<\/li>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/java-qa-engineer?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_QAJA&amp;utm_term=regular&amp;utm_content=240721\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f QA-\u0438\u043d\u0436\u0435\u043d\u0435\u0440 \u043d\u0430 JAVA<\/a><\/p>\n<\/li>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/csharp?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_CDEV&amp;utm_term=regular&amp;utm_content=240721\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f C#-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/a><\/p>\n<\/li>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/game-dev?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_GAMEDEV&amp;utm_term=regular&amp;utm_content=240721\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0438\u0433\u0440 \u043d\u0430 Unity<\/a><\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041e\u0442 \u043e\u0441\u043d\u043e\u0432 \u2014 \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0443<\/strong><\/p>\n<ul>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/algo?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_algo&amp;utm_term=regular&amp;utm_content=240721\">\u041a\u0443\u0440\u0441 \u00ab\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445\u00bb<\/a><\/p>\n<\/li>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/cplus?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_CPLUS&amp;utm_term=regular&amp;utm_content=240721\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f C++ \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/a><\/p>\n<\/li>\n<li>\n<p>  <a href=\"https:\/\/skillfactory.ru\/cybersecurity?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_HACKER&amp;utm_term=regular&amp;utm_content=240721\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f \u042d\u0442\u0438\u0447\u043d\u044b\u0439 \u0445\u0430\u043a\u0435\u0440<\/a><\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0410 \u0442\u0430\u043a\u0436\u0435:<\/strong><\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/devops?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_DEVOPS&amp;utm_term=regular&amp;utm_content=240721\">\u041a\u0443\u0440\u0441 \u043f\u043e DevOps<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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:\/\/habr.com\/ru\/articles\/569412\/\"> https:\/\/habr.com\/ru\/articles\/569412\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a \u0441\u0442\u0430\u0440\u0442\u0443 \u043a\u0443\u0440\u0441\u0430 \u043e <a href=\"https:\/\/skillfactory.ru\/csharp?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_CDEV&amp;utm_term=regular&amp;utm_content=240721\">\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043d\u0430 C#<\/a> \u0434\u0435\u043b\u0438\u043c\u0441\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u0441\u0442\u0430\u0442\u044c\u0438 \u043e \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0445 \u043e\u0448\u0438\u0431\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 C# \u043e\u0442 \u041a\u0440\u0438\u0441\u0442\u043e\u0444\u0430 \u041d\u0430\u0441\u0430\u0440\u0440\u0435 \u2014 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0440\u0435\u0446\u0435\u043d\u0437\u0435\u043d\u0442\u0430 \u043a\u043d\u0438\u0433 Microsoft Press \u0432 \u0446\u0435\u043b\u043e\u043c \u0438, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043a\u043d\u0438\u0433\u0438 CLR via C# \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u041a\u0440\u0438\u0441\u0442\u043e\u0444 \u041d\u0430\u0441\u0430\u0440\u0440\u0435 \u2014 \u043e\u0434\u0438\u043d \u0438\u0437 \u0430\u0432\u0442\u043e\u0440\u043e\u0432 \u043a\u043d\u0438\u0433\u0438 Windows via C++.<\/p>\n<hr\/>\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043d\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 \u043c\u0443\u0441\u043e\u0440\u0430 (\u0434\u0430\u043b\u0435\u0435 \u2014 GC \u2014 Garbage Collector), \u043d\u043e, \u0447\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0442\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 GC \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0446\u0435\u043b\u044c \u2014 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0432\u044b\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043a\u043e\u0434\u0430 \u0438\u043b\u0438 \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u0438\u0445 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0434\u043e\u043b\u0433\u043e. \u041f\u043e\u043c\u043e\u0433\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c Criteo \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u0434, \u044f \u0441\u043e\u0431\u0440\u0430\u043b \u0438 \u0437\u0430\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u043d\u0442\u0438\u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 C#, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430\u043c \u0438\u0437 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 <a href=\"https:\/\/twitter.com\/KooKiz\">\u041a\u0435\u0432\u0438\u043d\u0430<\/a> \u043e <a href=\"https:\/\/kevingosse.medium.com\/performance-best-practices-in-c-b85a47bdd93a\">\u043a\u043e\u0434\u0435 \u0441 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u043c \u0437\u0430\u043f\u0430\u0445\u043e\u043c<\/a>. \u0412\u043e\u0442 \u0432\u044b\u0434\u0435\u0440\u0436\u043a\u0430 \u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u0438 \u043f\u043b\u043e\u0445\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u044f\u0445 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<h2>\u0424\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438 IDisposable<\/h2>\n<p>\u041d\u0430\u0447\u043d\u0451\u043c \u0441\u043e \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u00ab\u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430\u00bb \u2014 \u0441\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442. \u041f\u0438\u0448\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434, \u0438\u043c\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u2014 \u044d\u0442\u043e \u0438\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0441 \u043f\u0440\u0435\u0301\u0444\u0438\u043a\u0441\u043e\u043c <code>~<\/code>. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.object.finalize?WT.mc_id=DT-MVP-5003325\">Object.Finalize<\/a>, \u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0442\u0438\u043f\u0430 \u0441 \u0442\u0430\u043a\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f GC \u043e\u0441\u043e\u0431\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438 \u0441\u0441\u044b\u043b\u043a\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 <code>Finalization<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430 <code>Finalization<\/code> \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f, \u044d\u0442\u0430 \u0441\u0441\u044b\u043b\u043a\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u2014 <code>fReachable<\/code> \u2014 \u0438 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043a\u043e\u0440\u043d\u0435\u0432\u0430\u044f, \u043f\u043e\u043a\u0430 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a \u043d\u0435 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u043a\u043e\u0434 \u0435\u0451 \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u043e\u043d\u0440\u0430\u0434 \u041a\u043e\u043a\u043e\u0441\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0441\u0432\u043e\u0438\u0445 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0445<a href=\"https:\/\/twitter.com\/konradkokosa\"> \u0432\u0438\u0434\u0435\u043e <\/a>\u043e GC \u0438\u0437\u043d\u0443\u0442\u0440\u0438 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u0442\u0438\u043f\u0430, \u0433\u0434\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440, \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e, \u043e\u0436\u0438\u0434\u0430\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0431\u043e\u0440\u043a\u0438 \u043c\u0443\u0441\u043e\u0440\u0430 \u043f\u043e\u043a\u043e\u043b\u0435\u043d\u0438\u044f, \u0433\u0434\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0430\u044f \u0441\u0431\u043e\u0440\u043a\u0430 \u043c\u0443\u0441\u043e\u0440\u0430, \u0442. \u0435. <code>gen1<\/code>, \u0435\u0441\u043b\u0438 \u043e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0441\u044f \u0432 <code>gen0<\/code>, \u0438\u043b\u0438 <code>gen2<\/code>, \u0435\u0441\u043b\u0438 \u0432 <code>gen1<\/code>, \u0447\u0442\u043e \u0435\u0449\u0451 \u0445\u0443\u0436\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u0447\u0430\u0441\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u0433\u043e, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440. \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043e\u0442\u0432\u0435\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c. \u0424\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0447\u0438\u0449\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u043e\u0442 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 <code>COM<\/code> \u0438\u043b\u0438 <code>P\/Invoke<\/code> \u00ab\u043d\u0435\u0447\u0442\u043e\u00bb: \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u044b, \u043d\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u0438\u043b\u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.runtime.interopservices.marshal?WT.mc_id=DT-MVP-5003325\">Marshal<\/a>-\u0445\u0435\u043b\u043f\u0435\u0440\u044b \u043f\u0430\u043c\u044f\u0442\u044c. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u044f <code>IntPtr<\/code>, \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0437\u043d\u0430\u043a \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0438\u0445 \u0436\u0438\u0437\u043d\u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0435 \u0447\u0435\u0440\u0435\u0437 \u0445\u0435\u043b\u043f\u0435\u0440\u044b Marshal \u0438\u043b\u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 <code>P\/Invoke<\/code>. \u0418\u0449\u0438\u0442\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0442 <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.runtime.interopservices.safehandle?WT.mc_id=DT-MVP-5003325\">SafeHandle<\/a> \u043a\u043b\u0430\u0441\u0441, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u0430\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u044f\u0434\u0440\u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 IntPtr, \u0438\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u0432. \u0418\u0442\u0430\u043a, \u0432 99,9% \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d.<\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441: \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.idisposable?WT.mc_id=DT-MVP-5003325\">IDisposable<\/a>? \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 <code>Dispose()<\/code> \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 <code>IDisposable<\/code> \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 \u043c\u0443\u0441\u043e\u0440\u0430 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442, \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u043d\u0435 \u043f\u0440\u043e\u0434\u043b\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0438\u043a\u0430\u043a\u0438\u043c \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u043c \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u043c. <code>Dispose<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0435 \u0436\u0434\u0430\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0443 \u043c\u0443\u0441\u043e\u0440\u0430, \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044f\u0432\u043d\u043e \u043e\u0447\u0438\u0441\u0442\u0438\u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u043e\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430. <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440: \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0444\u0430\u0439\u043b \u0437\u0430 \u043a\u0443\u043b\u0438\u0441\u0430\u043c\u0438 .NET \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 API, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u0444\u0430\u0439\u043b\u043e\u043c \u0447\u0435\u0440\u0435\u0437 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u044f\u0434\u0440\u0430 \u0432 Windows \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u043c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c: \u0434\u0432\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043d\u0435 \u043f\u043e\u0432\u0440\u0435\u0434\u044f\u0442 \u0444\u0430\u0439\u043b \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0440\u0430\u0437\u043d\u044b\u0445 \u0431\u0430\u0439\u0442\u043e\u0432. \u042d\u0442\u043e \u0432\u0437\u0433\u043b\u044f\u0434 \u043d\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u0441 \u0432\u044b\u0441\u043e\u0442\u044b \u043f\u0442\u0438\u0447\u044c\u0435\u0433\u043e \u043f\u043e\u043b\u0451\u0442\u0430, \u043e\u0434\u043d\u0430\u043a\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0438 \u043e\u043d \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c. <\/p>\n<p>\u0414\u0440\u0443\u0433\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u0430\u0437\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439, \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0442\u044c \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u0440\u0435\u0435. \u0412\u043e \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445 \u043a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u044d\u0442\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u00ab\u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0442\u044c\u00bb \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0437\u0430 \u043a\u0443\u043b\u0438\u0441\u0430\u043c\u0438 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435. \u042d\u0442\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0445\u043e\u0440\u043e\u0448\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d <code>using<\/code>:<\/p>\n<pre><code class=\"cs\">using (var disposableInstance = new MyDisposable()) {    DoSomething(disposableInstance); }; \/\/ the instance will be cleanup and its resources released<\/code><\/pre>\n<p>\u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u043a\u043e\u0434 \u0432\u044b\u0448\u0435 \u0432 \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code class=\"cs\">var disposableInstance = new MyDisposable(); try {    DoSomething(disposableInstance); } finally {    disposableInstance?.Dispose(); }<\/code><\/pre>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u0435\u043d <code>IDisposable<\/code>? \u041c\u043e\u0439 \u043e\u0442\u0432\u0435\u0442 \u043f\u0440\u043e\u0441\u0442: \u043e\u043d \u043d\u0443\u0436\u0435\u043d, \u043a\u043e\u0433\u0434\u0430 \u043a\u043b\u0430\u0441\u0441 \u0432\u043b\u0430\u0434\u0435\u0435\u0442 \u043f\u043e\u043b\u044f\u043c\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0445 <code>IDisposable<\/code> \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u0435\u0441\u043b\u0438 \u043e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 (\u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u043b\u0430\u0441\u044c \u0432\u044b\u0448\u0435). \u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>IDisposable.Dispose<\/code> \u043f\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438, \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u043b\u043e\u0441\u044c \u0432 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 C++. \u041f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439 \u044f\u0432\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441.<\/p>\n<p>\u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u044f \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u043f\u043e\u0447\u0435\u043c\u0443 \u043a\u043e\u0434 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Microsoft \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0439. \u0427\u0442\u043e\u0431\u044b \u00ab\u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c\u00bb \u043d\u0435\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0438\u043b\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u043d\u0438\u0436\u0435. \u0412\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u043a\u0430\u043a \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c, \u0442\u0430\u043a \u0438 <code>IDisposable.Dispose()<\/code>:<\/p>\n<pre><code class=\"cs\">var disposableInstance = new MyDisposable(); try {    DoSomething(disposableInstance); } finally {    disposableInstance?.Dispose(); }<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>IDisposable.Dispose()<\/code> \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0435 <code>_disposed<\/code>. \u0415\u0441\u043b\u0438 <code>_disposed<\/code> \u0440\u0430\u0432\u043d\u043e <code>true<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0439\u043c\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u0442\u0438\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0432\u043e \u0432\u0441\u0435\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445 \u043a\u043b\u0430\u0441\u0441\u0430 \u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <code>ObjectDisposedException<\/code>.<\/p>\n<p>\u0421\u043f\u0440\u043e\u0441\u0438\u0442\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u043a\u043e\u0433\u0434\u0430 <code>disposing<\/code> \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c <code>true<\/code> \u0438\u043b\u0438 <code>false<\/code>: \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u044f \u0441\u043e\u043c\u043d\u0435\u0432\u0430\u044e\u0449\u0438\u0445\u0441\u044f, \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u0441\u043a\u0430\u0436\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0438\u0437 \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430, \u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u2014 \u0438\u0437 <code>Dispose<\/code>.  \u0417\u0430\u0447\u0435\u043c \u0434\u0430\u0432\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0435 \u0438\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0432 <code>IDisposable<\/code>? \u041f\u043e\u0447\u0435\u043c\u0443 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>disposing<\/code>? \u042f \u0434\u0443\u043c\u0430\u044e, \u0438\u0437\u0431\u044b\u0442\u043e\u043a <code>Dispose<\/code> \u0443\u0431\u0438\u0432\u0430\u0435\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0449\u0435. \u0412\u043e\u0442 \u043c\u043e\u044f \u0432\u0435\u0440\u0441\u0438\u044f:<\/p>\n<pre><code class=\"cs\">class DisposableMe : IDisposable {     private bool _disposed = false;      \/\/ 1. field that implements IDisposable     \/\/ 2. field that stores \"native resource\" (ex: IntPtr)      ~DisposableMe()     {         Cleanup(\"called from GC\" != null);     }           \/\/ = true      public void Dispose()     {         Cleanup(\"not from GC\" == null);     }           \/\/ = false          ... }<\/code><\/pre>\n<p>\u042f \u0442\u0430\u043a\u0436\u0435 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043b <code>Dispose(bool disposing)<\/code> \u0432 <code>Cleanup(bool fromGC)<\/code>:<\/p>\n<pre><code class=\"cs\"> private void Cleanup(bool fromGC)  {      if (_disposed)          return;       try      {          \/\/ always clean up the NATIVE resources          if (fromGC)              return;           \/\/ clean up managed resources ONLY if not called from GC      }      finally      {          _disposed = true;           if (!fromGC)              GC.SuppressFinalize(this);      }  }<\/code><\/pre>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u043e\u0441\u0442\u044b. \u0417\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u0435 \u0438\u0445:<\/p>\n<ul>\n<li>\n<p>\u041d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u0442. \u0435. \u043f\u043e\u043b\u044f <code>IntPtr<\/code>, \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0447\u0438\u0449\u0430\u0442\u044c\u0441\u044f \u0432\u0441\u0435\u0433\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0423\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b, \u0442. \u0435. \u043f\u043e\u043b\u044f <code>IDisposable<\/code>, \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0442\u0438\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0438\u0437 <code>Dispose<\/code>, \u043d\u043e \u043d\u0435 \u0438\u0437 GC.<\/p>\n<\/li>\n<\/ul>\n<p>\u041b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u043e\u043b\u0435 <code>_disposed<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437. \u0417\u0434\u0435\u0441\u044c \u043e\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0432 <code>true<\/code>, \u0434\u0430\u0436\u0435 \u043a\u043e\u0433\u0434\u0430 \u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, \u043e\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u0438 \u043f\u043e\u0437\u0434\u043d\u0435\u0435. \u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0432\u0430\u0436\u043d\u0430\u044f \u0434\u0435\u0442\u0430\u043b\u044c: \u0432\u044b\u0437\u043e\u0432 <code>GC.SuppressFinalize(this)<\/code> \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 GC, \u0447\u0442\u043e \u0435\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0443\u0442\u0438\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0437  <code>Finalization<\/code>:<\/p>\n<ul>\n<li>\n<p>\u0412\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437 <code>Dispose<\/code> (\u043d\u0435 \u0438\u0437 GC), \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u043e\u0434\u043b\u0435\u0432\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p>\u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0444\u0438\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0438\u043d\u0430\u0447\u0435 \u043e\u043d \u0432\u044b\u0437\u043e\u0432\u0435\u0442 Cleanup, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u0442 \u043a \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0443, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <code>_disposed<\/code> \u0438\u0441\u0442\u0438\u043d\u043d\u043e.<\/p>\n<\/li>\n<\/ul>\n<p>\u0420\u0435\u0447\u044c \u0438\u0434\u0451\u0442 \u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u0434 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043e, \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u044b\u043c. \u0412\u0441\u0435\u0433\u0434\u0430 \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u0443\u0439\u0442\u0435 \u043c\u0435\u0436\u0434\u0443 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e, \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u043e\u0439 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u044f, \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430.<\/p>\n<h2>\u0414\u0430\u0439\u0442\u0435 \u0441\u043f\u0438\u0441\u043a\u0443 \u0437\u0430\u043f\u0430\u0441 \u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e<\/h2>\n<p>\u0421\u043e\u0437\u0434\u0430\u0432\u0430\u044f <code>List<\/code> \u0438\u043b\u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438, \u0434\u0430\u0439\u0442\u0435 \u0435\u043c\u0443 \u0437\u0430\u043f\u0430\u0441 \u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439 \u0432 .NET \u043e\u0431\u044b\u0447\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435, \u0440\u0430\u0437\u043c\u0435\u0440 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432; \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e:<\/p>\n<ol>\n<li>\n<p>\u0412\u044b\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432. <\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0435\u0436\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043f\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u043d\u0435\u0433\u043e.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u043f\u0440\u0435\u0436\u043d\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f.<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cs\">var resultList = new List&lt;...>(); foreach (var item in otherList) {     resultList.Add(...); }<\/code><\/pre>\n<h2>StringBuilder \u043b\u0443\u0447\u0448\u0435 +\/+=<\/h2>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u0440\u0435\u0301\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0431\u043e\u0440\u043e\u043a \u043c\u0443\u0441\u043e\u0440\u0430 \u0438 \u0441\u043d\u0438\u0437\u0438\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u041a\u043b\u0430\u0441\u0441 <code>string<\/code> \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u0435\u043d, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u0430 \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, .NET Framework \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043d\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<p>\u041f\u0440\u0438 \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u043e\u043a \u0438\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 <code>Concat<\/code>, <code>+<\/code> \u0438 <code>+=<\/code>. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u043e \u044d\u0442\u043e \u0434\u043b\u044f \u0446\u0438\u043a\u043b\u043e\u0432 \u0438 \u0447\u0430\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0412 \u043a\u043e\u0434\u0435 \u043d\u0438\u0436\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435 <code>StringBuilder<\/code>:<\/p>\n<pre><code class=\"cs\">var productIds = string.Empty; while (match.Success) {    productIds += match.Groups[2].Value + \"\\n\";    match = match.NextMatch(); }<\/code><\/pre>\n<p>\u0412 \u0446\u0438\u043a\u043b\u0430\u0445 \u0441\u0442\u0430\u0440\u0430\u0439\u0442\u0435\u0441\u044c \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a. \u041d\u0438\u0436\u0435 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f <code>SearchValue.ToUpper()<\/code>:<\/p>\n<pre><code class=\"cs\">if (SelectedColumn == Resources.Journaux.All &amp;&amp; !String.IsNullOrEmpty(SearchValue))     source = model.DataSource.Where(x => x.ItemId.Contains(SearchValue)         || x.ItemName.ToUpper().Contains(SearchValue.ToUpper())         || x.ItemGroupName.ToUpper().Contains(SearchValue.ToUpper())         || x.CountingGroupName.ToUpper().Contains(SearchValue.ToUpper()));     if (SelectedColumn == Resources.Journaux.ItemNumber)     source = model.DataSource.Where(x => x.ItemId.ToUpper().Contains(SearchValue.ToUpper()));     if (SelectedColumn == Resources.Journaux.ItemName)     source = model.DataSource.Where(x => x.ItemName.ToUpper().Contains(SearchValue.ToUpper()));     if (SelectedColumn == Resources.Journaux.ItemGroup)     source = model.DataSource.Where(x => x.ItemGroupName.ToUpper().Contains(SearchValue.ToUpper()));   if (SelectedColumn == Resources.Journaux.CountingGroup)     source = model.DataSource.Where(x => x.CountingGroupName.ToUpper().Contains(SearchValue.ToUpper()));<\/code><\/pre>\n<p>\u042d\u0444\u0444\u0435\u043a\u0442 \u0443\u0441\u0443\u0433\u0443\u0431\u043b\u044f\u0435\u0442\u0441\u044f <code>Where()<\/code>, \u0433\u0434\u0435 \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438! \u042d\u0442\u043e \u0432\u0435\u0440\u043d\u043e \u0438 \u0434\u043b\u044f \u0442\u0438\u043f\u043e\u0432, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445 \u0434\u043e\u0441\u0442\u0443\u043f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<pre><code>if (!uriBuilder.ToString().EndsWith(\".\", true, invCulture))<\/code><\/pre>\n<p><code>ToString()<\/code> \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e:<\/p>\n<pre><code class=\"cs\">if (uriBuilder[uriBuilder.Length - 1] != '.')<\/code><\/pre>\n<h2>\u0418\u043d\u0442\u0435\u0440\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a<\/h2>\n<p>\u041b\u0443\u0447\u0448\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f, \u0430 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435:<\/p>\n<pre><code>var allCampaignStatuses =     ((CampaignActivityStatus[])Enum.GetValues(typeof(CampaignActivityStatus)))    .ToList();<\/code><\/pre>\n<p>\u042d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c.<\/p>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u043d\u043e \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0432\u0430\u0436\u043d\u043e\u0435: \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044f \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c CLR<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-384334","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/384334","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=384334"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/384334\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=384334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=384334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=384334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}