Questions tagged «default-interface-member»

1
如何调用默认方法而不是具体实现
为什么在C#8中更改了默认接口方法的行为?过去,以下代码(当未发布默认接口方法的演示时): interface IDefaultInterfaceMethod { // By default, this method will be virtual, and the virtual keyword can be here used! virtual void DefaultMethod() { Console.WriteLine("I am a default method in the interface!"); } } interface IOverrideDefaultInterfaceMethod : IDefaultInterfaceMethod { void IDefaultInterfaceMethod.DefaultMethod() { Console.WriteLine("I am an overridden default method!"); } } …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.