Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>C# has the following access.</p> <ul> <li><code>public</code> - everyone can see it</li> <li><code>private</code> - only things inside the class can see it</li> <li><code>protected</code> - only things inside the class, or inside derived classes can see it</li> <li><code>internal</code> - only things inside the assembly (dll or exe) can see it</li> <li><code>protected internal</code> - only things inside the class or derived classes can see it, and only if they are in the same assembly</li> </ul> <p>You have only 2 options:</p> <ul> <li>As <a href="https://stackoverflow.com/questions/1324629/c-class-namespace-access/1324655#1324655">Neil mentioned</a>, you can use <code>internal</code>, and split your code up into 2 assemblies - one for John and one for Paul.</li> <li>As you have already mentioned, you can use <code>private</code>, and nest all the JohnSecret classes inside the outer John class. <a href="https://stackoverflow.com/questions/1324629/c-class-namespace-access/1324687#1324687">paracycle's tip of using partial classes</a> makes this reasonably nice.</li> </ul> <p>Note: to make multiple assemblies you must make multiple projects inside visual studio.</p> <hr> <p>From a pragmatic point of view, does it really matter if the directories are fenced off from each other like that? There are no security benefits in using access modifiers as anyone can always use reflection to easily call your private/internal methods anyway.</p> <p>The main benefit it gives you is keeping clutter out of your way when coding, but you've already put them in different namespaces, which should help with clutter anyway.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload