Can we make a class private in namespace?

 Posted by Rajni.Shekhar on 4/3/2012 | Category: C# Interview questions | Views: 3600 | Points: 40

No we can not create a class private in namespace. because namespace elements can not be private, protected or protected internal.

If you will create it, compiler will trow compile time error.

namespace TestNamespace{

private class testClass{

comiple time error: "Elements defined in a namespace cannot be explicitly declared as private, protected, or protected internal"

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Akiii on: 4/4/2012 | Points: 10
Nice question rajani ..

Thanks and Regards

Login to post response