Can We Declare Private Class In A Namespace

Can We Declare Private Class In A Namespace


  • 26 Jan, 2012

    No. If you try to create a private class in a Namespace, Compiler will throw a compile time error ?Namespace elements cannot be explicitly declared as private, protected, or protected internal?.Reason: The message says it all. Classes can only be declared as private, protected or protected internal when declared as nested classes, other than that, it doesn't make sense to declare a class with a visibility that makes it unusable, even in the same module. Top level classes cannot be private, they are "internal" by default, and you can just make them public to make them visible from outside your DLL.

    Comments Received:
    Please give your suggestions and feedback:

2009-2016 downloadmela.com. All rights reserved.