Run the following code:
// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0
// Copyright (c) Microsoft Corporation. All rights reserved.
// Metadata version: v4.0.30319
.assembly extern System.Runtime
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....:
.ver 4:2:1:0
}
.assembly extern System.Console
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....:
.ver 4:1:1:0
}
.assembly debug4
{
.custom instance void [System.Runtime]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [System.Runtime]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
// --- The following custom attribute is added automatically, do not uncomment -------
// .custom instance void [System.Runtime]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [System.Runtime]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 07 01 00 00 00 00 )
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module debug4.exe
// MVID: {BF25DEA9-6A9E-48D2-B381-F5C84106EB57}
.imagebase 0x00400000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x006B0000
// =============== CLASS MEMBERS DECLARATION ===================
.class interface public abstract auto ansi B
implements C
{
.method private hidebysig virtual final
instance char C.F1(int32 pB) cil managed
{
.override C::F1
// Code size 3 (0x3)
.maxstack 8
IL_0000: ldc.i4.s 66
IL_0002: ret
} // end of method B::C.F1
} // end of class B
.class interface public abstract auto ansi C
{
.method public hidebysig newslot abstract virtual
instance char F1(int32 pC) cil managed
{
} // end of method C::F1
} // end of class C
.class private auto ansi beforefieldinit A
extends [System.Runtime]System.Object
implements B,
C
{
.method private hidebysig newslot virtual final
instance char C.F1(int32 pA) cil managed
{
.override C::F1
// Code size 3 (0x3)
.maxstack 8
IL_0000: ldc.i4.s 65
IL_0002: ret
} // end of method A::C.F1
.method private hidebysig instance void
Test() cil managed
{
// Code size 15 (0xf)
.maxstack 8
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldc.i4.1
IL_0003: call instance char C::F1(int32)
IL_0008: call void [System.Console]System.Console::WriteLine(char)
IL_000d: nop
IL_000e: ret
} // end of method A::Test
.method private hidebysig static void Main() cil managed
{
.entrypoint
// Code size 13 (0xd)
.maxstack 8
IL_0000: nop
IL_0001: newobj instance void A::.ctor()
IL_0006: call instance void A::Test()
IL_000b: nop
IL_000c: ret
} // end of method A::Main
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [System.Runtime]System.Object::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method A::.ctor
} // end of class A
// =============================================================
// *********** DISASSEMBLY COMPLETE ***********************
// WARNING: Created Win32 resource file debug4.res
Observed: 'A' is printed.
Expected: An exception should be thrown, an abstract method in an interface is called non-virtually IL_0003: call instance char C::F1(int32)
Run the following code:
Observed: 'A' is printed.
Expected: An exception should be thrown, an abstract method in an interface is called non-virtually
IL_0003: call instance char C::F1(int32)