下面可以通过编译了,只是主函数你要修改namespace console3
{ interface IBase
{
void FWay(int i) ; //error
}
interface ILeft: IBase
{
new void FWay (int i) ;
}
interface IRight: IBase
{
void G( ) ;
}
interface IDerived: ILeft, IRight
{
} class class1
{
void main(IDerived d) //error
{
d. FWay (1) ; // 调用ILeft. FWay
((IBase)d). FWay (1) ; // 调用IBase. FWay
((ILeft)d). FWay (1) ; // 调用ILeft. FWay
((IRight)d). FWay (1) ; // 调用IBase. FWay
}
}
}你在void前加了看不见的字符
你把void前面的空格删除(一直删到上一行) 试试!
其他的也是如此;
是copy过来的代码中的空格,标点符号可能是在中文输入状态下进行的,所以有错.
帮你修改了一下,下面可以运行了using System;namespace ConsoleApplication5
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
/// interface IBase
{
void FWay(int i) ; //error
} interface ILeft: IBase
{
new void FWay (int i) ;
} interface IRight: IBase
{
void G( ) ;
} class myclass :IBase
{
#region IBase 成员 public void FWay(int i)
{
Console.WriteLine(i.ToString());
} #endregion }
interface IDerived: ILeft, IRight
{
}
[STAThread]
static void Main(string[] args)
{
myclass d = new myclass();
d.FWay (1) ; // 调用ILeft. FWay
((IBase)d).FWay (1) ; // 调用IBase.FWay
((ILeft)d).FWay (1) ; // 调用ILeft.FWay
((IRight)d).FWay (1) ; // 调用IBase.FWay
}
}
}
你把void前面的空格删除(一直删到上一行) 试试!
其他的也是如此;
是copy过来的代码中的空格,标点符号可能是在中文输入状态下进行的,所以有错.