Why does Resharper think that an inner class with property “SomeValue” hides a property with the same name in the outer class?

I’m guessing because it means using SomeValue in the inner class means you get the value assigned to the inner class rather than the outer class.

Consider this:

public static class Super
{
  public static class Sub
  {
    public static string OtherValue {get{return SomeValue;}}

    // Remove this line and OtherValue will return Outer
    public static string SomeValue { get{return "Inner"; }}
  }

  public static string SomeValue { get{return "Outer"; }}
}

Currently Super.Sub.OtherValue will return Inner but removing the line I’ve commented will cause it to return Outer

Leave a Comment