Take the 2-minute tour ×

Is there any existence of private class in C# except in Inner classes?

share|improve this question
add comment

4 Answers

Simply NO. Nothing unless its in a nested Class



  • Struct members, including nested classes and structs, can be declared as public, internal, or private. Class members, including nested classes and structs, can be public, protected internal, protected, internal, or private. The access level for class members and struct members, including nested classes and structs, is private by default. Private nested types are not accessible from outside the containing type.

  • Derived classes cannot have greater accessibility than their base types. In other words, you cannot have a public class B that derives from an internal class A. If this were allowed, it would have the effect of making A public, because all protected or internal members of A are accessible from the derived class.

    You can enable specific other assemblies to access your internal types by using the InternalsVisibleToAttribute.

share|improve this answer
add comment

No, there isn't. You cannot have a private class unless it is nested.

share|improve this answer
thnx for ur answer –  Vinod Bhatt Feb 8 '11 at 11:07
add comment

In what scenario other then for an innter class would you like to have a 'private' class ?

You can use the internal modifier to create a class that is only visible in the current assembly.

// the class below is only visible inside the assembly in where it was declared
internal class MyClass
share|improve this answer
add comment

No. What would the scope of such a class be?

share|improve this answer
I'd guess OP is more experienced in Java, which would allow visibility within the same source file. –  Peter Taylor Feb 5 '11 at 11:33
add comment

Your Answer


