{"id":649,"date":"2016-11-23T20:32:01","date_gmt":"2016-11-23T20:32:01","guid":{"rendered":"https:\/\/ibex.tech\/windows-iot\/?p=165"},"modified":"2022-09-13T15:40:20","modified_gmt":"2022-09-13T14:40:20","slug":"define-2","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/uwp-programming-in-c\/define-uwp-programming-in-c\/define-2","title":{"rendered":"#define"},"content":{"rendered":"<p>#define isn&#8217;t used in C#&nbsp;(well it is sort of, see below, but the general usage isn&#8217;t available)<\/p>\n<p>You can&#8217;t use it to create macros. Bloody annoying, but get over it &#8211; you can&#8217;t!&nbsp; So instead use constants.<\/p>\n<p>See <a href=\"https:\/\/ibex.tech\/windows-iot\/windows-iot\/programming-in-c\/memory\/constants\">constants here<\/a><\/p>\n<h4>\n\tHow #define is used in C#<\/h4>\n<p>#define is only used to create something to test against (e.g. #if DEBUG #endif)<\/p>\n<p>#define can only appear at the start of a file.<\/p>\n<p>#define only has scope in the file it is defined in.<\/p>\n<h4>\n\tGlobal defines in C#<\/h4>\n<p>You can define for an entire project in Project Properties &gt;&nbsp;Build &gt; Conditional compilation symbols<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>#define isn&#8217;t used in C#&nbsp;(well it is sort of, see below, but the general usage isn&#8217;t available) You can&#8217;t use it to create macros. Bloody annoying, but get over it &#8211; you can&#8217;t!&nbsp; So instead use constants. See constants here How #define is used in C# #define is only used to create something to test [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[136],"tags":[],"class_list":["post-649","post","type-post","status-publish","format-standard","hentry","category-define-uwp-programming-in-c"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/649","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=649"}],"version-history":[{"count":1,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/649\/revisions"}],"predecessor-version":[{"id":1187,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/649\/revisions\/1187"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}