Hi...
Maybe I'm just being especially obtuse today, but I've been perplexed by how
some of the protection levels have been working with nested classes in C#. I
have a parent class that wants to be able define sub-object to return to
consumers but wants to really clamp down on how much is exposed to the
consumer - for example, I wanted to make consumers unable to instantiate the
sub-objects on their own.
Originally, i'd hoped something like
public class a {
public class b {
private or protected b() { //constructor }
...
}
....
}
would allow only the parent class to invoke the a.b constructor, but that
doesn't appear to be the case. In the protection level table I found on
MSDN, it just didn't look like protection levels addressed the concept of a
parent class restricting access to a child class directly.
Then I went looking for an old C++ construct to try - the friend class
declaration - and I found C# didn't have it. If I could declare a.b's
constructor private and then declare a a friend class of a.b that might do
what I was getting at.
Am I just missing some point here?
Thanks
_mark