﻿
{"id":3155,"date":"2015-08-05T15:31:14","date_gmt":"2015-08-05T15:31:14","guid":{"rendered":"http:\/\/www.gencayyildiz.com\/blog\/?p=3155"},"modified":"2015-08-05T15:32:07","modified_gmt":"2015-08-05T15:32:07","slug":"c-6-0-try-catch-filtreleme","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/c-6-0-try-catch-filtreleme\/","title":{"rendered":"C# 6.0 &#8211; Try Catch Filtreleme"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Hata kontrol mekanizmas\u0131 Try Catch bloklar\u0131, yaz\u0131l\u0131mlar\u0131m\u0131z\u0131n mant\u0131k hatalar\u0131nda tam bir can kurtaran g\u00f6revi \u00fcstlenmektedir.B\u00f6yle \u00f6nemli bir i\u015fi \u00fcstlenen bir yap\u0131da \u015fartl\u0131 ifadelerin kullan\u0131lmamas\u0131 b\u00fcy\u00fck bir eksiklikti.C# 6.0 ile bu bo\u015fluk doldurulmu\u015ftur.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    class MatematikIslemleri\r\n    {\r\n        public static string Bol(int Sayi1, int Sayi2)\r\n        {\r\n            try\r\n            {\r\n                return Sayi1 \/ Sayi2 + &quot;&quot;;\r\n            }\r\n            catch when (Sayi1 &lt; 25)\r\n            {\r\n                return &quot;25'ten k\u00fc\u00e7\u00fck&quot;;\r\n            }\r\n            catch when (Sayi1 &gt; 25)\r\n            {\r\n                return &quot;25'ten b\u00fcy\u00fck.&quot;;\r\n            }\r\n        }\r\n    }\r\n<\/pre>\n<p>Yukar\u0131da g\u00f6rd\u00fc\u011f\u00fcn\u00fcz MatematikIslemleri.cs isimli bir s\u0131n\u0131fa static yap\u0131da Bol isimli bir metod tan\u0131mlanm\u0131\u015ft\u0131r.Buradaki ama\u00e7 , s\u0131f\u0131ra b\u00f6l\u00fcnme neticesinde try catch blo\u011funun devreye sokulmas\u0131 ve yap\u0131m\u0131zdaki yenili\u011fi \u00f6rneklemektir.<\/p>\n<p>Sayi1, Sayi2&#8217;de ki s\u0131f\u0131r de\u011ferine b\u00f6l\u00fcnd\u00fc\u011f\u00fcnde program ak\u0131\u015f\u0131 try catch blo\u011funa d\u00fc\u015fecektir ve catch bloklar\u0131nda &#8220;when&#8221; komutuyla Sayi1 de\u011fi\u015fkenindeki de\u011fere g\u00f6re \u015fartl\u0131 bir \u00e7al\u0131\u015fma ger\u00e7ekle\u015ftirecektir.E\u011fer Sayi1 de\u011fi\u015fkenin de\u011feri 25&#8217;ten k\u00fc\u00e7\u00fckse &#8220;25&#8217;ten k\u00fc\u00e7\u00fck&#8221; de\u011filse &#8220;25&#8217;ten b\u00fcy\u00fck&#8221; de\u011ferini ekrana yazd\u0131racakt\u0131r.Hal b\u00f6yleyken bunu her hangi bir duruma genelleyebilir ve bu yap\u0131n\u0131n esnek kullan\u0131m\u0131n\u0131n verdi\u011fi rahatl\u0131\u011f\u0131n tad\u0131n\u0131 \u00e7\u0131karabilirsiniz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n        static void Main(string&#x5B;] args)\r\n        {\r\n            string Sonuc = MatematikIslemleri.Bol(5, 0);\r\n            Console.Write(Sonuc);\r\n            Console.Read();\r\n        }\r\n<\/pre>\n<p><a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2015\/08\/C-6.0-Try-Catch-Filitreleme.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2015\/08\/C-6.0-Try-Catch-Filitreleme.png\" alt=\"C# 6.0 - Try Catch Filitreleme\" width=\"105\" height=\"70\" class=\"aligncenter size-full wp-image-3160\" \/><\/a><\/p>\n<p>\u0130yi \u00e7al\u0131\u015fmalar diliyorum.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hata kontrol mekanizmas\u0131 Try Catch bloklar\u0131, yaz\u0131l\u0131mlar\u0131m\u0131z\u0131n mant\u0131k hatalar\u0131nda tam bir can kurtaran g\u00f6revi \u00fcstlenmektedir.B\u00f6yle \u00f6nemli bir i\u015fi \u00fcstlenen bir yap\u0131da \u015fartl\u0131 ifadelerin kullan\u0131lmamas\u0131 b\u00fcy\u00fck bir eksiklikti.C# 6.0 ile bu bo\u015fluk doldurulmu\u015ftur. class MatematikIslemleri&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":3014,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,720],"tags":[27,724,732,731,66],"class_list":["post-3155","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-sharp-c","category-c-6-0","tag-c","tag-c-6-0","tag-filtreleme","tag-try-catch-filtreleme","tag-try-catch"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/3155","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/comments?post=3155"}],"version-history":[{"count":0,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/3155\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media\/3014"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=3155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=3155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=3155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}