{"id":29,"date":"2016-02-10T16:28:16","date_gmt":"2016-02-10T16:28:16","guid":{"rendered":"https:\/\/ibex.tech\/csharp\/?p=29"},"modified":"2022-02-17T06:24:15","modified_gmt":"2022-02-17T06:24:15","slug":"variables","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/c-sharp\/memory\/variables","title":{"rendered":"Variables"},"content":{"rendered":"<p>\n\tThe structure below shows the various basic types of C#&nbsp;and the types they map to in the .Net framework.\n<\/p>\n<table cellpadding=\"0\" cellspacing=\"0\">\n<colgroup>\n<col width=\"130\" \/>\n<col width=\"100\" \/>\n<col width=\"198\" \/>\n<col width=\"214\" \/>\n\t<\/colgroup>\n<tbody>\n<tr>\n<td>\n\t\t\t\t<strong>C# Short Name<\/strong>\n\t\t\t<\/td>\n<td>\n\t\t\t\t<strong>.Net Class<\/strong>\n\t\t\t<\/td>\n<td>\n\t\t\t\t<strong>Declaration<\/strong>\n\t\t\t<\/td>\n<td>\n\t\t\t\t<strong>Description<\/strong>\n\t\t\t<\/td>\n<\/tr>\n<tr>\n<td>\n\t\t\t\tbool\n\t\t\t<\/td>\n<td>\n\t\t\t\tBoolean\n\t\t\t<\/td>\n<td>\n\t\t\t\tbool isValid = true;\n\t\t\t<\/td>\n<td>\n<p>\n\t\t\t\t\t8 bit true or false\n\t\t\t\t<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n\t\t\t\tsbyte\n\t\t\t<\/td>\n<td>\n\t\t\t\tSByte\n\t\t\t<\/td>\n<td>\n\t\t\t\tsbyte b = -1\n\t\t\t<\/td>\n<td>\n\t\t\t\tsigned 8 bit integer\n\t\t\t<\/td>\n<\/tr>\n<tr>\n<td>\n\t\t\t\tbyte\n\t\t\t<\/td>\n<td>\n\t\t\t\tByte\n\t\t\t<\/td>\n<td>\n\t\t\t\tbyte b = 1;\n\t\t\t<\/td>\n<td>\n\t\t\t\t8 bit unsigned integer\n\t\t\t<\/td>\n<\/tr>\n<tr>\n<td>\n\t\t\t\tchar\n\t\t\t<\/td>\n<td>\n\t\t\t\tChar\n\t\t\t<\/td>\n<td>\n\t\t\t\tchar = &#39;a&#39;\n\t\t\t<\/td>\n<td>\n\t\t\t\t16 bit single Unicode character\n\t\t\t<\/td>\n<\/tr>\n<tr>\n<td>\n\t\t\t\tshort\n\t\t\t<\/td>\n<td>\n\t\t\t\tInt16\n\t\t\t<\/td>\n<td>\n\t\t\t\tshort s = 123;\n\t\t\t<\/td>\n<td>\n\t\t\t\t16bit signed integer\n\t\t\t<\/td>\n<\/tr>\n<tr>\n<td>\n\t\t\t\tushort\n\t\t\t<\/td>\n<td>\n\t\t\t\tUInt16\n\t\t\t<\/td>\n<td>\n\t\t\t\tushort s = 15;\n\t\t\t<\/td>\n<td>\n\t\t\t\t16bit unsigned integer\n\t\t\t<\/td>\n<\/tr>\n<tr>\n<td>\n\t\t\t\tint\n\t\t\t<\/td>\n<td>\n\t\t\t\tInt32\n\t\t\t<\/td>\n<td>\n\t\t\t\tint i = -1000000;\n\t\t\t<\/td>\n<td>\n\t\t\t\t32bit signed integer\n\t\t\t<\/td>\n<\/tr>\n<tr>\n<td>\n\t\t\t\tuint\n\t\t\t<\/td>\n<td>\n\t\t\t\tUInt32\n\t\t\t<\/td>\n<td>\n\t\t\t\tuint i = 50000;\n\t\t\t<\/td>\n<td>\n\t\t\t\t32bit unsigned integer\n\t\t\t<\/td>\n<\/tr>\n<tr>\n<td>\n\t\t\t\tlong\n\t\t\t<\/td>\n<td>\n\t\t\t\tInt64\n\t\t\t<\/td>\n<td>\n\t\t\t\tlong = 2000;\n\t\t\t<\/td>\n<td>\n\t\t\t\t64 bit signed integer\n\t\t\t<\/td>\n<\/tr>\n<tr>\n<td>\n\t\t\t\tulong\n\t\t\t<\/td>\n<td>\n\t\t\t\tUInt64\n\t\t\t<\/td>\n<td>\n\t\t\t\tulong = 2000;\n\t\t\t<\/td>\n<td>\n\t\t\t\t64 bit unsigned integer\n\t\t\t<\/td>\n<\/tr>\n<tr>\n<td>\n\t\t\t\tfloat\n\t\t\t<\/td>\n<td>\n\t\t\t\tSingle\n\t\t\t<\/td>\n<td>\n\t\t\t\tfloat f = 1.04f;\n\t\t\t<\/td>\n<td>\n\t\t\t\t4 byte single precision floating point\n\t\t\t<\/td>\n<\/tr>\n<tr>\n<td>\n\t\t\t\tdouble\n\t\t\t<\/td>\n<td>\n\t\t\t\tDouble\n\t\t\t<\/td>\n<td>\n\t\t\t\tdouble d = 1.0E-13\n\t\t\t<\/td>\n<td>\n\t\t\t\t8 byte double precision floating point\n\t\t\t<\/td>\n<\/tr>\n<tr>\n<td>\n\t\t\t\tdecimal\n\t\t\t<\/td>\n<td>\n\t\t\t\tDecimal\n\t\t\t<\/td>\n<td>\n\t\t\t\t&nbsp;\n\t\t\t<\/td>\n<td>\n\t\t\t\t16 byte precise fractional or integral type that can represent decimal numbers with 29 significant digits\n\t\t\t<\/td>\n<\/tr>\n<tr>\n<td>\n\t\t\t\tstring\n\t\t\t<\/td>\n<td>\n\t\t\t\tString\n\t\t\t<\/td>\n<td>\n\t\t\t\tstring s = &quot;abcd&quot;;\n\t\t\t<\/td>\n<td>\n\t\t\t\tA sequence of unicode characters\n\t\t\t<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\n\tBinary Values<br \/>\n<\/h4>\n<p>\n\tYou can&#39;t specify a binary value in C# &#8211; specify in hexadecimal instead.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The structure below shows the various basic types of C#&nbsp;and the types they map to in the .Net framework. C# Short Name .Net Class Declaration Description bool Boolean bool isValid = true; 8 bit true or false sbyte SByte sbyte b = -1 signed 8 bit integer byte Byte byte b = 1; 8 bit [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-29","post","type-post","status-publish","format-standard","hentry","category-memory"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/29","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=29"}],"version-history":[{"count":5,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/29\/revisions"}],"predecessor-version":[{"id":212,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/29\/revisions\/212"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=29"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=29"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=29"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}