﻿
{"id":219,"date":"2012-03-18T19:02:57","date_gmt":"2012-03-18T19:02:57","guid":{"rendered":"http:\/\/www.gencayyildiz.com\/blog\/?p=219"},"modified":"2012-05-28T13:03:10","modified_gmt":"2012-05-28T13:03:10","slug":"cta-stringbuilder-sinifi","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/cta-stringbuilder-sinifi\/","title":{"rendered":"C# StringBuilder S\u0131n\u0131f\u0131"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Bu yaz\u0131mda C# ta StringBuilder s\u0131n\u0131f\u0131ndan bahsedece\u011fim.StringBuilder dedi\u011fimiz s\u0131n\u0131f,string verilerin + operat\u00f6r\u00fcyle birle\u015fme i\u015fleminin ayn\u0131s\u0131n\u0131 yapmaktad\u0131r.Ancak + operat\u00f6r\u00fcyle stringler birle\u015ftirilirken bellekte birs\u00fcr\u00fc ge\u00e7i\u00e7i string ifadeler olu\u015fturulur.Bu i\u015flemlerde b\u00fcy\u00fck oranda performans kayb\u0131na sebep olmaktad\u0131r.Sonucta bu ifadelerin yan yana birle\u015fmi\u015f hali elde edilmeye \u00e7al\u0131\u015f\u0131lmaktad\u0131r.Ve bu i\u015flemi StringBuilder s\u0131n\u0131f\u0131n\u0131 kullanarak yaparsak b\u00fcy\u00fck oranda performans kayb\u0131n\u0131 \u00f6nlemi\u015f oluruz.<br \/>\n<!--more--> <span style=\"color: #ff0000;\"><strong>Metodlar\u0131<\/strong><\/span><br \/>\n<span style=\"color: #99cc00;\">Append() :<\/span>Bu metod sayesinde,parametresine g\u00f6nderilen veriler string bi\u00e7imde birle\u015ftirilecektir.int,bool,string,byte,decimal,dauble,float vs&#8230; tipten verileri al\u0131p stringe \u00e7evirip birle\u015ftirme i\u015flemi yapar.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            StringBuilder sb = new StringBuilder();\r\n            sb.Append(3);\r\n            sb.Append(4);\r\n            MessageBox.Show(sb.ToString());\r\n<\/pre>\n<p>Yukar\u0131da g\u00f6rd\u00fc\u011f\u00fcn\u00fcz gibi Append() metodunun int tipinden de\u011fer alan overload\u0131n\u0131 kullanarak 3 ve 4 say\u0131lar\u0131n\u0131 string olarak birle\u015ftirdik.Sonu\u00e7 olarak mesaj kutusunda 34 yazacakt\u0131r.<br \/>\nBir ba\u015fka \u00f6rnek,<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            StringBuilder sb = new StringBuilder();\r\n            sb.Append(&quot;Gen\u00e7ay&quot;);\r\n            sb.Append(Environment.NewLine);\r\n\/\/Alt sat\u0131ra ge\u00e7er. \\n ayn\u0131 i\u015fi g\u00f6rmektedir.\r\n            sb.Append(&quot;Y\u0131ld\u0131z&quot;);\r\n            MessageBox.Show(sb.ToString());\r\n<\/pre>\n<p>Yukardaki kod blo\u011funun \u00e7\u0131kt\u0131s\u0131,<br \/>\nGen\u00e7ay<br \/>\nY\u0131ld\u0131z olacakt\u0131r.<br \/>\nPeki Append() metodunda string leri birle\u015ftirirken bir alt sat\u0131ra ge\u00e7mek i\u00e7in \u00f6zel karakter ya da Environment.Newline&#8217;m\u0131 yazmam\u0131z gerekiyor?Hay\u0131r.AppendLine() metodu sayesinde eklenen veriden sonra bir alt sat\u0131ra ge\u00e7i\u015f yapabiliyoruz.<br \/>\n<span style=\"color: #99cc00;\">AppendLine() :<\/span>Bu metod sayesinde, parametresine gelen de\u011feri ekledikten sonra bir alt sat\u0131ra otomatik ge\u00e7i\u015f yapar.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            StringBuilder sb = new StringBuilder();\r\n            sb.AppendLine(&quot;Gen\u00e7ay&quot;);\r\n\/\/Gen\u00e7ay'\u0131 ekledikten sonra otomatikman bir alt sat\u0131ra ge\u00e7i\u015f yapar ve Y\u0131ld\u0131z'\u0131 ekler.\r\n            sb.Append(&quot;Y\u0131ld\u0131z&quot;);\r\n            MessageBox.Show(sb.ToString());\r\n<\/pre>\n<p>Yukardaki kod blo\u011funun \u00e7\u0131kt\u0131s\u0131,<br \/>\nGen\u00e7ay<br \/>\nY\u0131ld\u0131z olacakt\u0131r.<\/p>\n<p>StringBuilder s\u0131n\u0131f\u0131n\u0131n kullan\u0131\u015fl\u0131 iki metodu i\u015flemlerimizde yeterli olacakt\u0131r.Bir sonraki yaz\u0131mda g\u00f6r\u00fc\u015fmek \u00fczere.<br \/>\n\u0130yi \u00e7al\u0131\u015fmalar.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Bu yaz\u0131mda C# ta StringBuilder s\u0131n\u0131f\u0131ndan bahsedece\u011fim.StringBuilder dedi\u011fimiz s\u0131n\u0131f,string verilerin + operat\u00f6r\u00fcyle birle\u015fme i\u015fleminin ayn\u0131s\u0131n\u0131 yapmaktad\u0131r.Ancak + operat\u00f6r\u00fcyle stringler birle\u015ftirilirken bellekte birs\u00fcr\u00fc ge\u00e7i\u00e7i string ifadeler olu\u015fturulur.Bu i\u015flemlerde b\u00fcy\u00fck oranda performans kayb\u0131na sebep olmaktad\u0131r.Sonucta bu&#46;&#46;&#46;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[147],"class_list":["post-219","post","type-post","status-publish","format-standard","hentry","category-c-sharp-c","tag-stringbuilder"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/219","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=219"}],"version-history":[{"count":0,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/219\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}