{"id":570,"date":"2022-05-25T13:35:43","date_gmt":"2022-05-25T12:35:43","guid":{"rendered":"https:\/\/ibex.tech\/csharp\/?p=570"},"modified":"2022-05-25T13:35:44","modified_gmt":"2022-05-25T12:35:44","slug":"inconsistent-accessibility-field-type-is-less-accessible-than-field","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/c-sharp\/issues\/inconsistent-accessibility-field-type-is-less-accessible-than-field","title":{"rendered":"Inconsistent accessibility: field type is less accessible than field"},"content":{"rendered":"\n<p>Example error message: Inconsistent accessibility: field type &#8216;MyPublicClass&#8217; is less accessible than field &#8216;MyPublicObject.MyPublicStaticClassObject&#8217;<\/p>\n\n\n\n<p>We often use a public static class ApMain in our projects:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>namespace my_projects_namespace\r\n{\r\n\tpublic static class ApMain\r\n\t{<\/code><\/pre>\n\n\n\n<p>Within this we create other objects as public static, so they can be accessed throughout the app:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\tpublic static MyClass MyClass1;<\/code><\/pre>\n\n\n\n<p>These can then be accessed using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\tApMain.MyClass1<\/code><\/pre>\n\n\n\n<p>If you get this error when you add a new class to it, its because you&#8217;ve not made the new class public, you should have this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>namespace my_projects_namespace\n{\n\tpublic class Udp\n\t{<\/code><\/pre>\n\n\n\n<p>Not this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>namespace my_projects_namespace\n{\n\tclass Udp\n\t{<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Example error message: Inconsistent accessibility: field type &#8216;MyPublicClass&#8217; is less accessible than field &#8216;MyPublicObject.MyPublicStaticClassObject&#8217; We often use a public static class ApMain in our projects: Within this we create other objects as public static, so they can be accessed throughout the app: These can then be accessed using: If you get this error when you [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[50],"tags":[],"class_list":["post-570","post","type-post","status-publish","format-standard","hentry","category-issues"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/570","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=570"}],"version-history":[{"count":1,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/570\/revisions"}],"predecessor-version":[{"id":571,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/570\/revisions\/571"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}