{"id":89,"date":"2016-02-12T13:40:54","date_gmt":"2016-02-12T13:40:54","guid":{"rendered":"https:\/\/ibex.tech\/csharp\/?p=89"},"modified":"2022-02-17T06:24:15","modified_gmt":"2022-02-17T06:24:15","slug":"global-classes","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/c-sharp\/classes\/global-classes","title":{"rendered":"Global Classes"},"content":{"rendered":"<p>\n\tYou simply use a static class&nbsp;to provide global functionality. Static classes contain only static members and are not instantiated &#8211;&nbsp;essentially they are global functions and variables accessed via their class name (and namespace).\n<\/p>\n<p>\n\tIssues:\n<\/p>\n<p style=\"margin-left: 40px;\">\n\tThere is no constructor.<br \/>\n\tAny class you want to include must be static also\n<\/p>\n<p>\n\tAn example:\n<\/p>\n<pre>\r\n<code>\r\n\tpublic static class MyGlobalClassName\r\n\t{\r\n\t\tpublic static string Name;\r\n\t\tpublic static int aNumber;\r\n\t\tpublic static List&lt;string&gt; MyList = new List&lt;string&gt;();\r\n\r\n\t\tpublic static void SomeMethodName()\r\n\t\t{\r\n\t\t\tName = &quot;starting name&quot;;\r\n\t\t\taNumber = 5;\r\n\t\t}\r\n\t}\r\n<\/code><\/pre>\n<p>\n\t&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You simply use a static class&nbsp;to provide global functionality. Static classes contain only static members and are not instantiated &#8211;&nbsp;essentially they are global functions and variables accessed via their class name (and namespace). Issues: There is no constructor. Any class you want to include must be static also An example: public static class MyGlobalClassName { [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-89","post","type-post","status-publish","format-standard","hentry","category-classes"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/89","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=89"}],"version-history":[{"count":4,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/89\/revisions"}],"predecessor-version":[{"id":114,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/89\/revisions\/114"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=89"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=89"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}