﻿
{"id":217,"date":"2012-03-18T19:01:42","date_gmt":"2012-03-18T19:01:42","guid":{"rendered":"http:\/\/www.gencayyildiz.com\/blog\/?p=217"},"modified":"2012-05-28T13:03:15","modified_gmt":"2012-05-28T13:03:15","slug":"cta-generic-list-koleksiyon","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/cta-generic-list-koleksiyon\/","title":{"rendered":"C# Generic List Koleksiyon"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Bu yaz\u0131mda C#&#8217;ta Generic List koleksiyonuna de\u011finece\u011fim.Biliyoruz ki ArrayList koleksiyon yap\u0131s\u0131 mevcuttur ve \u00e7o\u011fu i\u015fimizi bu koleksiyon yap\u0131s\u0131yla g\u00f6rebiliyoruz.Ancak i\u00e7ine ald\u0131\u011f\u0131 elemanlar\u0131 object tipte al\u0131r.Bu y\u00fczden koleksiyon i\u00e7ine al\u0131nan elemanlara boxing i\u015flemi yap\u0131l\u0131r.<br \/>\n<!--more--><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nArrayList deneme = new ArrayList();\r\ndeneme.Add(&quot;Gen\u00e7ay&quot;);\r\ndeneme.Add(&quot;Y\u0131ld\u0131z&quot;);\r\ndeneme.Add(21);\r\ndeneme.Add(DateTime.Now);\r\n<\/pre>\n<p>Yukarda g\u00f6rd\u00fc\u011f\u00fcn\u00fcz gibi, ArrayList koleksiyon yap\u0131s\u0131na elemanlar\u0131 atarken object tipte al\u0131yor ve boxing i\u015flemi yap\u0131l\u0131yor.E\u011fer ben bu koleksiyondaki verilerimle \u00e7al\u0131\u015fmak istiyorsam s\u00fcrekli unboxing yapmak zorunda kalaca\u011f\u0131m.Ve g\u00f6rd\u00fc\u011f\u00fcn\u00fcz gibi yap\u0131n\u0131n i\u00e7inde sadece bir tek tip yok.String,int ve DateTime tipinden veriler object olarak koleksiyon da tutulabiliyor.Bu verilerle \u00e7al\u0131\u015f\u0131rken verinin tipini bilmemiz gerekiyor ve ona g\u00f6re unboxing yapmam\u0131z gerekiyor.<br \/>\nUzun laf\u0131n k\u0131sas\u0131, ArrayList kullan\u0131m\u0131n\u0131n sak\u0131ncalar\u0131ndan biride tip g\u00fcvenli\u011finin olmamas\u0131.<br \/>\nBu sorunlar program\u0131n ak\u0131\u015f\u0131nda karma\u015faya yol a\u00e7abilirler ve performans\u0131 negatif etkilerler.<\/p>\n<p>E\u011fer koleksiyon i\u00e7inde b\u00fct\u00fcn veriler ayn\u0131 tipte olacaksa ArrayList yerine Generic List koleksiyon yap\u0131s\u0131 kullan\u0131l\u0131r.(Genellikle class nesneleri i\u00e7in)<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nList&lt;int&gt; Sayilar=new List&lt;int&gt;();\r\n\/\/List&lt;int&gt; : Bu koleksiyon yap\u0131s\u0131na int tipinden ba\u015fka de\u011fer eklenemez.\r\nSayilar.Add(12);\r\nSayilar.Add(10);\r\nSayilar.Add(17);\r\nSayilar.Add(21);\r\n<\/pre>\n<p>Yukar\u0131da g\u00f6rd\u00fc\u011f\u00fcn\u00fcz yap\u0131 Generic List koleksiyon yap\u0131s\u0131d\u0131r.E\u011fer bu koleksiyona int tipinden olmayan bir veri eklersek program derlenmeyecektir.Object \u00e7al\u0131\u015fmad\u0131\u011f\u0131m\u0131z i\u00e7in boxing,unboxing olmaz.Performans\u0131 pozitif etkileyecektir.Sadece istedi\u011fimiz tipte veri alabildi\u011fi i\u00e7in tip g\u00fcvenli\u011fi korunmu\u015f olacakt\u0131r.<\/p>\n<p>\u015eimdilik bu kadar..\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#&#8217;ta Generic List koleksiyonuna de\u011finece\u011fim.Biliyoruz ki ArrayList koleksiyon yap\u0131s\u0131 mevcuttur ve \u00e7o\u011fu i\u015fimizi bu koleksiyon yap\u0131s\u0131yla g\u00f6rebiliyoruz.Ancak i\u00e7ine ald\u0131\u011f\u0131 elemanlar\u0131 object tipte al\u0131r.Bu y\u00fczden koleksiyon i\u00e7ine al\u0131nan elemanlara boxing i\u015flemi yap\u0131l\u0131r.<!-- 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":[145,146],"class_list":["post-217","post","type-post","status-publish","format-standard","hentry","category-c-sharp-c","tag-generic","tag-list"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/217","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=217"}],"version-history":[{"count":0,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/217\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=217"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=217"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}