2

Suppose I have a base class:

public class A {
    public float someValue;

    <Access Modifier Here> float SomeValue {
        get {
            return someValue;
        }
    }
}

And I want to derive from it:

public class B : A {
    public float SomeProperty {
        get {
            return SomeValue;
        }
    }
}

What access modifier would I use if I want to make the SomeValue property only available to the deriving class and not anywhere else?

Tayab
  • 311
  • 2
  • 13

1 Answers1

1

for only derived classes.. use protected

Protected means that access is limited to the containing class or types derived from the containing class.

Grizzly
  • 5,873
  • 8
  • 56
  • 109