interface temp
{
void Method();
}
public class my:temp
{
#region temp Members
public static void Method()
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
}
Error 1 'ConsoleApplication2.my' does not implement interface member 'ConsoleApplication2.temp.Method()'. 'ConsoleApplication2.my.Method()' is either static, not public, or has the wrong return type. C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\ConsoleApplication2\ConsoleApplication2\Program.cs 12 18 ConsoleApplication2
“ is either static”表示接口里是不允许有静态方法的。
另外:你可以从OO的角度去理解这个问题,interface是抽象的,而static是具体的,这两种东西如果放在一起,interface就失去原来的意义了!所以OO语言应该是都从语法上已经强制这这点:“is either static” ,即不允许任何interface里有任何静态的东西,不信你可以实验一下!