{"id":268,"date":"2011-12-04T15:37:29","date_gmt":"2011-12-04T15:37:29","guid":{"rendered":"http:\/\/www.kodcafe.com\/?p=268"},"modified":"2011-12-04T15:37:29","modified_gmt":"2011-12-04T15:37:29","slug":"c-sharp-ta-degiskenler","status":"publish","type":"post","link":"https:\/\/www.kodcafe.com\/?p=268","title":{"rendered":"C sharp ta de\u011fi\u015fkenler"},"content":{"rendered":"<p>C#&#8217;ta de\u011fi\u015fken tan\u0131mlama<\/p>\n<p>\u00c7o\u011fu programlama dilinde de\u011fi\u015fkenler kullan\u0131lmaya ba\u015flanmadan \u00f6nce tan\u0131mlan\u0131rlar. A\u015fa\u011f\u0131daki \u015fekli inceleyiniz.<br \/>\n<a href=\"http:\/\/www.kodcafe.com\/wp-content\/uploads\/2011\/12\/Variable_definition_in_c_sharp.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-269\" title=\"Variable_definition_in_c_sharp\" src=\"http:\/\/www.kodcafe.com\/wp-content\/uploads\/2011\/12\/Variable_definition_in_c_sharp.gif\" alt=\"\" width=\"141\" height=\"95\" \/><\/a><\/p>\n<p>Yukar\u0131daki \u015fekilde C#&#8217;ta de\u011fi\u015fken tan\u0131mlaman\u0131n nas\u0131l yap\u0131ld\u0131\u011f\u0131 anlat\u0131lm\u0131\u015ft\u0131r. De\u011fi\u015fken t\u00fcr\u00fc bellekte ayr\u0131lan g\u00f6zene\u011fin b\u00fcy\u00fckl\u00fc\u011f\u00fcn\u00fc belirtmemizi sa\u011flar. De\u011fi\u015fken ad\u0131 da bu g\u00f6zene\u011fe verdi\u011fimiz ad\u0131 belirtir. Do\u011fal olarak bu g\u00f6zenekteki veriye eri\u015fmek istedi\u011fimizde veya bu g\u00f6zenekteki veriyi de\u011fi\u015ftirmek istedi\u011fimizde bu ad\u0131 kullanaca\u011f\u0131z. Yukar\u0131daki \u015fekilde -2,147,483,648 ile 2,147,483,647 aras\u0131nda (s\u0131n\u0131rlar d\u00e2hil) bir de\u011fer tutabilen ve ad\u0131 &#8220;ad&#8221; olan bir bellek g\u00f6zene\u011fi olu\u015fturduk.<br \/>\n<!--more--><br \/>\nDe\u011fi\u015fkenlere de\u011fer atama<\/p>\n<p>\u00c7o\u011fu programlama dilinde de\u011fi\u015fkenler tan\u0131mland\u0131ktan sonra direkt olarak programda kullan\u0131labilirler. Ancak C#&#8217;ta de\u011fi\u015fkeni tan\u0131mlad\u0131ktan sonra ayr\u0131ca bir de ilk de\u011fer atamak zorunday\u0131z. Aksi bir durumda de\u011fi\u015fkeni program\u0131m\u0131z i\u00e7inde kullanamay\u0131z. De\u011fi\u015fkenlere de\u011fer atama \u015f\u00f6yle yap\u0131l\u0131r:<br \/>\nad=5;<br \/>\nBurada ad de\u011fi\u015fkenine 5 de\u011ferini atad\u0131k. Bu en basit de\u011fer atama y\u00f6ntemidir. Ayr\u0131ca \u015funlar da m\u00fcmk\u00fcnd\u00fcr:<\/p>\n<pre>int a=5;\nint b, c, d, e;\nint f=10, g, m=70;<\/pre>\n<p>Birinci sat\u0131rda tan\u0131mlama ve de\u011fer vermeyi ayn\u0131 sat\u0131rda yapt\u0131k. \u0130kincisinde ayn\u0131 t\u00fcrden birden fazla de\u011fi\u015fken tan\u0131mlad\u0131k. \u00dc\u00e7\u00fcnc\u00fc sat\u0131rda ise tan\u0131mlad\u0131\u011f\u0131m\u0131z de\u011fi\u015fkenlerin baz\u0131lar\u0131na de\u011fer verirken baz\u0131lar\u0131na vermedik.<br \/>\n[d\u00fczenle]De\u011fi\u015fken t\u00fcrleri<\/p>\n<p>Yukar\u0131da de\u011fi\u015fken tan\u0131mlarken de\u011fi\u015fken t\u00fcr\u00fc i\u00e7in int kullanm\u0131\u015ft\u0131k. C#&#8217;ta bunun gibi farkl\u0131 kapasitelere sahip bir hayli daha de\u011fi\u015fken t\u00fcr\u00fc vard\u0131r. Ayr\u0131ca baz\u0131 de\u011fi\u015fken t\u00fcrleri say\u0131sal, baz\u0131lar\u0131 da metinseldir. Say\u0131sal t\u00fcrler a\u015fa\u011f\u0131daki tabloda listelenmi\u015ftir:<br \/>\nT\u00fcr Boyut Kapasite \u00d6rnek<\/p>\n<pre>byte 1 bayt 0, ..., 255 (tam say\u0131) byte a=5;\nsbyte 1 bayt -128, ..., 127 (tam say\u0131) sbyte a=5;\nshort 2 bayt -32768, ..., 32767 (tam say\u0131) short a=5;\nushort 2 bayt 0, ..., 65535 (tam say\u0131) ushort a=5;\nint 4 bayt -2147483648, ..., 2147483647 (tam say\u0131) int a=5;\nuint 4 bayt 0, ..., 4294967295 (tam say\u0131) uint a=5;\nlong 8 bayt -9223372036854775808, ..., 9223372036854775807 (tam say\u0131) long a=5;\nulong 8 bayt 0, ..., 18446744073709551615 (tam say\u0131) ulong a=5;\nfloat 4 bayt \u00b11.5*10-45, ..., \u00b13.4*1038 (reel say\u0131) float a=5F; veya float a=5f;\ndouble 8 bayt \u00b15.0*10-324, ..., \u00b11.7*10308 (reel say\u0131) double a=5; veya double a=5d; veya double a=5D;\ndecimal 16 bayt \u00b11.5*10-28, ..., \u00b17.9*1028 (reel say\u0131) decimal a=5M; veya decimal a=5m;<\/pre>\n<p>Dikkat ettiyseniz baz\u0131 de\u011fi\u015fken t\u00fcrlerinde de\u011fer atarken de\u011ferin sonuna bir karakter eklenmi\u015f, bu de\u011fi\u015fken t\u00fcrlerindeki de\u011fi\u015fkenlere de\u011fer atarken siz de bunlara dikkat etmelisiniz. S\u0131ra geldi metinsel t\u00fcrlere:<br \/>\nT\u00fcr Boyut A\u00e7\u0131klama \u00d6rnek<br \/>\nchar 2 bayt Tek bir karakteri tutar. char a=&#8217;h&#8217;;<br \/>\nstring S\u0131n\u0131rs\u0131z Metin tutar. string a=&#8221;Ben bir zaman kayb\u0131y\u0131m, beni bo\u015fver hocam&#8221;;<br \/>\nString t\u00fcr\u00fcne ayr\u0131ca char ve\/veya string sabit ya da de\u011fi\u015fkenler + i\u015faretiyle eklenip atanabilir. \u00d6rnekler:<\/p>\n<pre>\nchar a='g';\nstring b=\"deneme\";\nstring c=a+b+\"Viki\"+'m';<\/pre>\n<p>C#&#8217;ta hem metinsel hem de say\u0131sal olmayan t\u00fcrler de vard\u0131r:<br \/>\nbool<br \/>\nKo\u015fullu yap\u0131larda kullan\u0131l\u0131r. Bool t\u00fcr\u00fcnden de\u011ferlere true, false veya 24;<br \/>\nobject<br \/>\nBu de\u011fi\u015fken t\u00fcr\u00fcne her t\u00fcrden veri atanabilir. \u00d6rnekler:<\/p>\n<pre>\nobject a=5;\nobject b='k';\nobject c=\"metin\";\nobject d=12.7f;<\/pre>\n<p>Asl\u0131nda C#&#8217;taki b\u00fct\u00fcn de\u011fi\u015fken t\u00fcrleri object t\u00fcr\u00fcnden t\u00fcremi\u015ftir. Bu y\u00fczden object t\u00fcr\u00fc di\u011ferlerinin ta\u015f\u0131d\u0131\u011f\u0131 b\u00fct\u00fcn \u00f6zellikleri ta\u015f\u0131r. Ancak \u015fimdilik bunu d\u00fc\u015f\u00fcnmenize gerek yok. Bu, nesneye dayal\u0131 programlaman\u0131n \u00f6zellikleriyle ilgili.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>C#&#8217;ta de\u011fi\u015fken tan\u0131mlama \u00c7o\u011fu programlama dilinde de\u011fi\u015fkenler kullan\u0131lmaya ba\u015flanmadan \u00f6nce tan\u0131mlan\u0131rlar. A\u015fa\u011f\u0131daki \u015fekli inceleyiniz. Yukar\u0131daki \u015fekilde C#&#8217;ta de\u011fi\u015fken tan\u0131mlaman\u0131n nas\u0131l yap\u0131ld\u0131\u011f\u0131 anlat\u0131lm\u0131\u015ft\u0131r. De\u011fi\u015fken t\u00fcr\u00fc bellekte ayr\u0131lan g\u00f6zene\u011fin b\u00fcy\u00fckl\u00fc\u011f\u00fcn\u00fc belirtmemizi sa\u011flar. De\u011fi\u015fken ad\u0131 da bu g\u00f6zene\u011fe verdi\u011fimiz ad\u0131 belirtir. Do\u011fal olarak bu g\u00f6zenekteki veriye eri\u015fmek istedi\u011fimizde veya bu g\u00f6zenekteki veriyi de\u011fi\u015ftirmek istedi\u011fimizde bu ad\u0131 kullanaca\u011f\u0131z. Yukar\u0131daki [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":98,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-268","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-sharp"],"_links":{"self":[{"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=\/wp\/v2\/posts\/268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=268"}],"version-history":[{"count":0,"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=\/wp\/v2\/posts\/268\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=\/"}],"wp:attachment":[{"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kodcafe.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}