【发布时间】:2014-02-26 13:00:45
【问题描述】:
为什么我无法访问 S 类方法?为什么我能够在 M 类中创建具有相同名称的方法?
public class S
{
public S()
{
}
public int myFunc(int a, int b)
{
return a + b;
}
}
public class M:S
{
public M()
{
}
public string myFunc(int a, int b)
{
return (a + b).ToString();
}
}
public class Test
{
public static void Main(string[] args)
{
M mm = new M();
mm.myFunc(1,2); // Why I am not able to access S class myFunc
}
}
【问题讨论】:
-
为什么忽略编译器的警告信息?你认为它只是为了给编译器开发者一些事情做吗?
标签: c# oop inheritance