为什么 Resharper 认为具有属性“SomeValue”的内部类在外部类中隐藏同名属性?
给出以下代码:
public static class Super
{
public static class Inner
{
public static string SomeValue { get; set; }
}
public static string SomeValue { get; set; }
}
Resharper 告诉我 Super.Inner.SomeValue 隐藏了外部类的属性。
到底是怎么回事?您有两个不同的引用(Super.SomeValue
和 Super.Inner.SomeValue
)。而且(据我所知)您不能使用一个引用来表示另一个变量。
我发现 Resharper 有时是错误的。但通常不会。所以我想知道它在这里想什么。
有什么想法吗?
Given the following code:
public static class Super
{
public static class Inner
{
public static string SomeValue { get; set; }
}
public static string SomeValue { get; set; }
}
Resharper tells me that Super.Inner.SomeValue
hides a property from the outer class.
How is there hiding going on? You have two distinct references (Super.SomeValue
and Super.Inner.SomeValue
). And (as far as I know) you cannot use one reference to mean the other variable.
I have found that Resharper is wrong sometimes. But not usually. So I would like to know what it is thinking here.
Any Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜测是因为这意味着在内部类中使用
SomeValue
意味着您获得分配给内部类而不是外部类的值。考虑一下:
目前
Super.Sub.OtherValue
将返回Inner
,但删除我注释的行将导致它返回Outer
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:
Currently
Super.Sub.OtherValue
will returnInner
but removing the line I've commented will cause it to returnOuter