Is it possible in C# to define a private class without nesting in a parent class? Below is a simplified example of what I'm trying to do
public abstract class ClassA<T>
{
public T Value { get; set; }
public ClassA(T value)
{
Value = value;
}
}
private class ClassB : ClassA<int>
{
public ClassB(int value)
: base(value)
{
}
}
I'd like for ClassB
to only be accessible by ClassA
. I'm wondering if what I'm trying to do is possible if the two classes are in the same file. Basically, it would be nice to hide extensions of ClassA
, but I'd rather not nest too many classes.