﻿
{"id":6233,"date":"2017-05-10T00:09:54","date_gmt":"2017-05-10T00:09:54","guid":{"rendered":"http:\/\/www.gencayyildiz.com\/blog\/?p=6233"},"modified":"2017-05-10T00:09:54","modified_gmt":"2017-05-10T00:09:54","slug":"cta-gostericipointer-gostericiler-arasinda-tur-donusumleri-v","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/cta-gostericipointer-gostericiler-arasinda-tur-donusumleri-v\/","title":{"rendered":"C#\u2019ta G\u00f6sterici(Pointer) &#8211; G\u00f6stericiler Aras\u0131nda T\u00fcr D\u00f6n\u00fc\u015f\u00fcmleri &#8211; V"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Merhaba,<\/p>\n<p>C#&#8217;ta g\u00f6stericileri tam teferruatl\u0131 ele ald\u0131\u011f\u0131m\u0131z yaz\u0131 dizimize be\u015finci makalemizden &#8220;G\u00f6stericiler Aras\u0131nda T\u00fcr D\u00f6n\u00fc\u015f\u00fcmleri&#8221; ba\u015fl\u0131\u011f\u0131yla devam ediyoruz. Yaz\u0131 dizimizi takip edebilmeniz i\u00e7in bir \u00f6nceki yazm\u0131\u015f oldu\u011fumuz <a href=\"http:\/\/www.gencayyildiz.com\/blog\/cta-gostericipointer-gosterici-bildirimi-ve-gosterici-operatorleri-iv\/\" target=\"_blank\">C#\u2019ta G\u00f6sterici(Pointer) \u2013 G\u00f6sterici Bildirimi ve G\u00f6sterici Operat\u00f6rleri \u2013 IV<\/a> ba\u015fl\u0131kl\u0131 makaleyi referans alabilir ve ilgili makale arac\u0131l\u0131\u011f\u0131yla yaz\u0131 dizimizin di\u011fer makalelerine eri\u015febilirsiniz.<\/p>\n<p>Evet&#8230; \u015eimdi hi\u00e7 vakit kaybetmeden esas konumuza giri\u015f yapal\u0131m.<\/p>\n<p>G\u00f6stericiler, basit de\u011fi\u015fkenler misali t\u00fcr d\u00f6n\u00fc\u015f\u00fcmlerini destekleyen bir yap\u0131ya sahiptirler.<br \/>\n\u00d6rnek olarak a\u015fa\u011f\u0131daki kod bloklar\u0131n\u0131 inceleyiniz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n--- \u00d6rnek 1 ---\r\n            unsafe\r\n            {\r\n                int a = 123;\r\n                int* apointer = &amp;a;\r\n\r\n                char c = 'h';\r\n                char* cpointer = &amp;c;\r\n                Console.WriteLine(*cpointer);\r\n\r\n                cpointer = (char*)apointer;\r\n                Console.WriteLine(*cpointer);\r\n            }\r\n<\/pre>\n<p><a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-G\u00f6stericiler-Aras\u0131nda-T\u00fcr-D\u00f6n\u00fc\u015f\u00fcmleri-V.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-G\u00f6stericiler-Aras\u0131nda-T\u00fcr-D\u00f6n\u00fc\u015f\u00fcmleri-V.png\" alt=\"C#\u2019ta G\u00f6sterici(Pointer) - G\u00f6stericiler Aras\u0131nda T\u00fcr D\u00f6n\u00fc\u015f\u00fcmleri - V\" width=\"44\" height=\"67\" class=\"aligncenter size-full wp-image-6239\" \/><\/a><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n--- \u00d6rnek 2 ---\r\n            unsafe\r\n            {\r\n                int a = 123;\r\n                int* apointer = &amp;a;\r\n                Console.WriteLine(*apointer);\r\n\r\n                char c = 'h';\r\n                char* cpointer = &amp;c;\r\n\r\n                apointer = (int*)cpointer;\r\n                Console.WriteLine(*apointer);\r\n            }\r\n<\/pre>\n<p><a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-G\u00f6stericiler-Aras\u0131nda-T\u00fcr-D\u00f6n\u00fc\u015f\u00fcmleri-V-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-G\u00f6stericiler-Aras\u0131nda-T\u00fcr-D\u00f6n\u00fc\u015f\u00fcmleri-V-1.png\" alt=\"C#\u2019ta G\u00f6sterici(Pointer) - G\u00f6stericiler Aras\u0131nda T\u00fcr D\u00f6n\u00fc\u015f\u00fcmleri - V.PNG\" width=\"50\" height=\"66\" class=\"aligncenter size-full wp-image-6240\" \/><\/a><\/p>\n<p>G\u00f6rd\u00fc\u011f\u00fcn\u00fcz gibi iki \u00f6rnektede &#8220;int*&#8221; ve &#8220;char*&#8221; t\u00fcr\u00fcnden i\u015faret\u00e7iler aras\u0131nda bir d\u00f6n\u00fc\u015f\u00fcm ger\u00e7ekle\u015ftirilmi\u015ftir. Dikkat ederseniz g\u00f6stericiler aras\u0131nda d\u00f6n\u00fc\u015f\u00fcm a\u00e7\u0131k\u00e7a belirtilmeli, yani bilin\u00e7li t\u00fcr d\u00f6n\u00fc\u015f\u00fcm\u00fc ger\u00e7ekle\u015ftirilmelidir.<\/p>\n<p>E\u011fer ki a\u015fa\u011f\u0131daki gibi g\u00f6stericiler aras\u0131nda bilin\u00e7siz olarak t\u00fcr d\u00f6n\u00fc\u015f\u00fcm\u00fc yapmaya \u00e7al\u0131\u015f\u0131rsan\u0131z derleme zaman\u0131nda hata alacaks\u0131n\u0131z.<br \/>\n<a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-G\u00f6stericiler-Aras\u0131nda-T\u00fcr-D\u00f6n\u00fc\u015f\u00fcmleri-V-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-G\u00f6stericiler-Aras\u0131nda-T\u00fcr-D\u00f6n\u00fc\u015f\u00fcmleri-V-2.png\" alt=\"C#\u2019ta G\u00f6sterici(Pointer) - G\u00f6stericiler Aras\u0131nda T\u00fcr D\u00f6n\u00fc\u015f\u00fcmleri - V\" width=\"183\" height=\"148\" class=\"aligncenter size-full wp-image-6243\" \/><\/a><\/p>\n<p>G\u00f6stericiler aras\u0131nda yap\u0131lan t\u00fcr d\u00f6n\u00fc\u015f\u00fcm\u00fcnde g\u00f6stericinin say\u0131sal de\u011feri de\u011fi\u015fmez. De\u011fi\u015fen \u015fey g\u00f6stericinin t\u00fcr\u00fcd\u00fcr.<br \/>\n<strong><em>Peki bu g\u00f6stericinin say\u0131sal de\u011feri nedir?<\/em><\/strong><br \/>\nG\u00f6stericilerin adres bilgileridir. Bir g\u00f6sterici i\u015faretledi\u011fi de\u011fi\u015fkenin adres bilgisini tam say\u0131 \u015feklinde tutmaktad\u0131r. Bu say\u0131y\u0131 okumak i\u00e7in i\u015faret\u00e7i referans\u0131n\u0131 &#8220;int&#8221; yahut &#8220;uint&#8221; tipinden tam say\u0131 de\u011ferlerine cast etmek yeterlidir.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n        static void Main(string&#x5B;] args)\r\n        {\r\n            unsafe\r\n            {\r\n                int a = 104;\r\n                int* apointer = &amp;a;\r\n                Console.WriteLine($&quot;apointer adres : {(int)apointer}&quot;);\r\n\r\n                char b = 'g';\r\n                char* bpointer = &amp;b;\r\n                Console.WriteLine($&quot;bpointer adres : {(uint)bpointer}&quot;);\r\n\r\n                bool c = true;\r\n                bool* cpointer = &amp;c;\r\n                Console.WriteLine($&quot;cpointer adres : {(uint)cpointer}&quot;);\r\n            }\r\n            Console.Read();\r\n        }\r\n<\/pre>\n<p>Yukar\u0131daki kod blo\u011funu incelerseniz e\u011fer &#8220;apointer&#8221;, &#8220;bpointer&#8221; ve &#8220;cpointer&#8221; isimli pointerlar\u0131n tuttuklar\u0131 bellek adresleri ekrana yazd\u0131r\u0131lm\u0131\u015ft\u0131r. Bu \u015fekilde projeyi derleyip \u00e7al\u0131\u015ft\u0131rd\u0131\u011f\u0131m\u0131z vakit a\u015fa\u011f\u0131daki ekran g\u00f6r\u00fcnt\u00fcs\u00fcne benzer sonu\u00e7la kar\u015f\u0131la\u015f\u0131lmaktad\u0131r.<br \/>\n<a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-G\u00f6stericiler-Aras\u0131nda-T\u00fcr-D\u00f6n\u00fc\u015f\u00fcmleri-V-3.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-G\u00f6stericiler-Aras\u0131nda-T\u00fcr-D\u00f6n\u00fc\u015f\u00fcmleri-V-3.png\" alt=\"C#\u2019ta G\u00f6sterici(Pointer) - G\u00f6stericiler Aras\u0131nda T\u00fcr D\u00f6n\u00fc\u015f\u00fcmleri - V.PNG\" width=\"206\" height=\"83\" class=\"aligncenter size-full wp-image-6246\" \/><\/a><br \/>\nProgram\u0131 her kapat\u0131p yeniden \u00e7al\u0131\u015ft\u0131rd\u0131\u011f\u0131m\u0131zda ilgili de\u011ferlerin de\u011fi\u015fmesi olduk\u00e7a do\u011fald\u0131r.<\/p>\n<p>Ayr\u0131ca a\u015fa\u011f\u0131daki \u00f6rnekte oldu\u011fu gibi herhangi bir g\u00f6stericinin say\u0131sal bile\u015fenine ula\u015fmak i\u00e7in pointer\u0131n ismini direkt olarak \u00e7a\u011f\u0131rmak yanl\u0131\u015f bir kullan\u0131m olacakt\u0131r.<br \/>\n<a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-G\u00f6stericiler-Aras\u0131nda-T\u00fcr-D\u00f6n\u00fc\u015f\u00fcmleri-V-4.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-G\u00f6stericiler-Aras\u0131nda-T\u00fcr-D\u00f6n\u00fc\u015f\u00fcmleri-V-4.png\" alt=\"C#\u2019ta G\u00f6sterici(Pointer) - G\u00f6stericiler Aras\u0131nda T\u00fcr D\u00f6n\u00fc\u015f\u00fcmleri - V.PNG\" width=\"389\" height=\"102\" class=\"aligncenter size-full wp-image-6249\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-G\u00f6stericiler-Aras\u0131nda-T\u00fcr-D\u00f6n\u00fc\u015f\u00fcmleri-V-4.png 389w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2017\/05\/C\u2019ta-G\u00f6stericiPointer-G\u00f6stericiler-Aras\u0131nda-T\u00fcr-D\u00f6n\u00fc\u015f\u00fcmleri-V-4-300x79.png 300w\" sizes=\"auto, (max-width: 389px) 100vw, 389px\" \/><\/a><br \/>\n\u0130lgili g\u00f6stericinin i\u015faretledi\u011fi bellek adresini elde etmek i\u00e7in bir \u00fcstteki kullan\u0131mda oldu\u011fu gibi d\u00f6n\u00fc\u015f\u00fcm\u00fcn a\u00e7\u0131k bir \u015fekilde pointer \u00fczerinde yap\u0131lmas\u0131(<em>(int)apointer ya da (uint)apointer gibi&#8230;<\/em>) gerekmektedir.<\/p>\n<p>E\u011fer ki d\u00f6n\u00fc\u015f\u00fcms\u00fcz t\u00fcm t\u00fcrler \u00fczerinde \u00e7al\u0131\u015fmak istiyorsak &#8220;void&#8221; anahtar s\u00f6zc\u00fc\u011f\u00fc olduk\u00e7a i\u015fimizi g\u00f6recektir. G\u00f6stericilerle ilgili \u00f6nceki makalelerimizde de\u011findi\u011fimiz &#8220;void&#8221; keyword\u00fc, pointer yap\u0131lar\u0131nda t\u00fcrden ba\u011f\u0131ms\u0131z bir i\u015faret\u00e7i ayarlamam\u0131za imkan sa\u011flamaktad\u0131r. &#8220;void&#8221; t\u00fcr\u00fcnden g\u00f6stericiler genellikle eski yaz\u0131lm\u0131\u015f API fonksiyonlar\u0131nda &#8220;void&#8221; parametre alan fonksiyonlar\u0131 programlar\u0131m\u0131z i\u00e7erisinden \u00e7a\u011f\u0131rmak i\u00e7in kullan\u0131l\u0131r.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            unsafe\r\n            {\r\n                void* x;\r\n                int a = 3;\r\n                bool b = false;\r\n                char c = 'a';\r\n                double d = 1.233;\r\n                x = &amp;a;\r\n                x = &amp;b;\r\n                x = &amp;c;\r\n                x = &amp;d;\r\n\r\n                Console.WriteLine(*(double*)x);\r\n            }\r\n<\/pre>\n<p>Yukar\u0131daki \u00f6rne\u011fi incelerseniz e\u011fer &#8220;void&#8221; t\u00fcr\u00fcnden pointerlarda d\u00f6n\u00fc\u015f\u00fcm yapmadan t\u00fcm t\u00fcrleri i\u015faretleyebilirken sadece ilgili pointer\u0131n de\u011ferini okumak istedi\u011fimiz vakit i\u015faretledi\u011fi t\u00fcre \u00f6zel bir cast i\u015flemi uygulamak mecburiyetimiz vard\u0131r.<\/p>\n<p>Evet arkada\u015flar&#8230;<br \/>\nBu makalemizde de pointerlar ile t\u00fcr d\u00f6n\u00fc\u015f\u00fcmlerini yeterince detayland\u0131rm\u0131\u015f oldu\u011fumuza inan\u0131yorum. Bir sonraki makalede g\u00f6stericilerde aritmatik i\u015flemlere de\u011finece\u011fiz.<\/p>\n<p>O halde \u015fimdilik g\u00f6r\u00fc\u015fmek \u00fczere diyelim&#8230;<br \/>\n\u0130yi \u00e7al\u0131\u015fmalar&#8230;<\/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>Merhaba, C#&#8217;ta g\u00f6stericileri tam teferruatl\u0131 ele ald\u0131\u011f\u0131m\u0131z yaz\u0131 dizimize be\u015finci makalemizden &#8220;G\u00f6stericiler Aras\u0131nda T\u00fcr D\u00f6n\u00fc\u015f\u00fcmleri&#8221; ba\u015fl\u0131\u011f\u0131yla devam ediyoruz. Yaz\u0131 dizimizi takip edebilmeniz i\u00e7in bir \u00f6nceki yazm\u0131\u015f oldu\u011fumuz C#\u2019ta G\u00f6sterici(Pointer) \u2013 G\u00f6sterici Bildirimi ve G\u00f6sterici&#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":3014,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[1782,1761,1780,1748,1781],"class_list":["post-6233","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-sharp-c","tag-c-pointer-tur-donusumu","tag-cta-gosterici","tag-gostericiler-arasinda-tur-donusumleri","tag-pointer","tag-pointer-tur-donusumu"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/6233","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=6233"}],"version-history":[{"count":0,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/6233\/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=6233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=6233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=6233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}