none
public / internal accessibility modifiers for types.

    Question

  • i can declare class with public, none and internal accessibility modifiers.

    1. public class Class1
    2. class Class1
    3. internal class Class1

    What is the difference between none ( 2. ) and internal ( 3.) modifiers ? In both i can use class only in the current assembly.
    Tuesday, January 22, 2008 12:39 PM

Answers

  • The difference, if any, depends on the language you're coding in.

     

    Assuming you're writing in C#; there's no difference at all as long as it's a top level (non-nested) type. It's just a matter of how explicit you want your code to be. In C# the default accessibility level is always "as restrictive as possible". For top level types that means internal, for nested types and type members it means private.

     

    Tuesday, January 22, 2008 12:57 PM