Class vs. Public Class

user1678541 picture user1678541 · Sep 12, 2012 · Viewed 44.6k times · Source

What is the difference between:

namespace Library{
    class File{
        //code inside it
   }
}

and:

namespace Library{
   public class File{
       //code inside it
   }
}

So what will be the difference between public class and class?

Answer

driis picture driis · Sep 12, 2012

Without specifying public the class is implicitly internal. This means that the class is only visible inside the same assembly. When you specify public, the class is visible outside the assembly.

It is also allowed to specify the internal modifier explicitly:

internal class Foo {}