Can classes be marked as protected or private ?

 Posted by Ddd on 1/17/2011 | Category: .NET Framework Interview questions | Views: 2937 | Points: 40
Answer:

Yes, a class can be marked as protected but we have to use the concept of nested classes for that .
For a class can be marked as private we have to use the concept of nested classes for that or declare a class in a structure
example: These are valid examples:
class A
{
protected class B
{
}
}

class C
{
private class D
{
}
}
//Class can also be private inside a structure
struct empz
{
private class Class3
{

}
}

It is OK.

If a class is declared below a namespace it cannot be marked as protected or private.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response