Can we make a class private in namespace?

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

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.
Example:

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
Akiii

Login to post response