I have the nub of the code like this:
public class OuterClass
{
public static InnerClass GetInnerClass()
{
return new InnerClass() { MyProperty =
I'm afraid there is no access modifier which allows that. You can create IInnerClass
interface and make the property readonly within interface declaration:
public class OuterClass
{
public static IInnerClass GetInnerClass()
{
return new InnerClass() { MyProperty = 1 };
}
public interface IInnerClass
{
int MyProperty { get; }
}
private class InnerClass : IInnerClass
{
public int MyProperty { get; set; }
}
}