I have a class Foo
with a function myName
in it.
Class bar
Inherits from Foo
and have a Property that is also called myName
I figured this should be OK since:
- The property will compile to
get_myName()
(so there would not be a collision with Foo::myName(int,int)
)
Foo::myName
has arguments while, obviously, the property does not (again, no colision).
Yet I still get the warning:
'Bar.myName' hides inherited member 'Foo.myName(int, int)'. Use the new keyword if hiding was intended.
Example Code:
public class Foo
{
public int myName(int a, int b)
{
return 0;
}
}
class Bar: Foo
{
int a;
int b;
int myName
{
get
{
return a + b;
}
}
}
Also, If I add to bar
the function:
int get_myName()
{
return a+b;
}
As expected, I get an error about the function previously declared.
So what is happening here? Is the property not allowing me to use ALL overloads of myName
in addition to get_myName()
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…