C# methods in interfaces are declared without using the virtual
keyword, and overridden in the derived class without using the override
keyword.
Is there a reason for this? I assume that it is just a language convenience, and obviously the CLR knows how to handle this under the covers (methods are not virtual by default), but are there other technical reasons?
Here is the IL that a derived class generates:
class Example : IDisposable {
public void Dispose() { }
}
.method public hidebysig newslot virtual final
instance void Dispose() cil managed
{
// Code size 2 (0x2)
.maxstack 8
IL_0000: nop
IL_0001: ret
} // end of method Example::Dispose
Notice that the method is declared virtual
final
in the IL.