{"id":201,"date":"2019-12-23T21:47:08","date_gmt":"2019-12-23T21:47:08","guid":{"rendered":"http:\/\/144.76.171.171\/blog\/?p=201"},"modified":"2019-12-23T21:47:08","modified_gmt":"2019-12-23T21:47:08","slug":"yerel-metotlar-local-functions","status":"publish","type":"post","link":"https:\/\/berenkudaygorun.com\/blog\/blog\/2019\/12\/23\/yerel-metotlar-local-functions\/","title":{"rendered":"Yerel Metotlar &#8211; Local Functions"},"content":{"rendered":"<p>Yerel metotlar isminden de anla\u015f\u0131laca\u011f\u0131 gibi asl\u0131nda yerel alanlarda olu\u015fturulan metotlard\u0131r. Bu \u00f6zellik C# 7.0 ile birlikte gelmi\u015ftir. Peki tam olarak ne zaman bu ihtiyac\u0131m\u0131z\u0131 g\u00f6r\u00fcr diyebilirsiniz. Hemen a\u00e7\u0131klayal\u0131m. Local Function'lar sadece kodland\u0131klar\u0131 metot i\u00e7erisinde kullan\u0131l\u0131rlar ve ge\u00e7erlilik alanlar\u0131 \u00f6nceden bellidir. Bundan dolay\u0131 metot i\u00e7erisinde tan\u0131mlanan yerel metotlar i\u00e7in bir eri\u015fim belirleyicisi kullan\u0131lmaz. Ayr\u0131ca bu metotlar statik olamazlar. <\/p>\n<ul>\n<li>Bir senaryo d\u00fc\u015f\u00fcnelim, projenizde mevcut bir metodu sadece tek bir alanda kulland\u0131ysan\u0131z bu metodu yerel metot olarak kullanman\u0131z kodunuzu daha okunur k\u0131lacakt\u0131r.<\/li>\n<li>\u00c7ok uzun metotlar \u00f6nerilmez ancak metodunuz i\u00e7erisinde uzun kodlar yazd\u0131ysan\u0131z belkide yerel metotlar ile kodunuzu daha k\u0131sa ve d\u00fczenli yazabilirsiniz. <\/li>\n<\/ul>\n<p>\u015eimdi bir kullan\u0131m \u00f6rne\u011fi g\u00f6relim ve sonraki yaz\u0131larda g\u00f6r\u00fc\u015fmek \u00fczere...<\/p>\n<pre><code class=\"language-csharp\">using System;\n\nnamespace ConsoleApp1\n{\n    class Program\n    {\n        static void Main(string[] args)\n        {\n           int HesaplaKaresi(int kenar)\n            {\n                return kenar * kenar;\n            }\n\n            Console.WriteLine(HesaplaKaresi(4));\n        }\n    }\n}\n<\/code><\/pre>\n<pre><code>16\nPress any key to continue . . .<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Yerel metotlar isminden de anla\u015f\u0131laca\u011f\u0131 gibi asl\u0131nda yerel alanlarda olu\u015fturulan metotlard\u0131r. Bu \u00f6zellik C# 7.0 ile birlikte gelmi\u015ftir. Peki tam olarak ne zaman bu ihtiyac\u0131m\u0131z\u0131&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/berenkudaygorun.com\/blog\/blog\/2019\/12\/23\/yerel-metotlar-local-functions\/\">Devam\u0131n\u0131 oku<span class=\"screen-reader-text\">Yerel Metotlar &#8211; Local Functions<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[160,167,166],"class_list":["post-201","post","type-post","status-publish","format-standard","hentry","category-c-sharp","tag-c-7-0","tag-local-functions","tag-yerel-metotlar","entry"],"_links":{"self":[{"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/posts\/201","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/comments?post=201"}],"version-history":[{"count":1,"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/posts\/201\/revisions"}],"predecessor-version":[{"id":202,"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/posts\/201\/revisions\/202"}],"wp:attachment":[{"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/media?parent=201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/categories?post=201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/berenkudaygorun.com\/blog\/wp-json\/wp\/v2\/tags?post=201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}