Skip to content

Commit ff8ace9

Browse files
authored
Update ComDefaultInterfaceAttribute.xml (dotnet#5234)
Correct example snippet
1 parent 510ee95 commit ff8ace9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

xml/System.Runtime.InteropServices/ComDefaultInterfaceAttribute.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,12 @@
5454
## Remarks
5555
Compilers do not necessarily respect the order in which interfaces are implemented. For example, suppose you have the following code:
5656
57-
```
58-
interface IBase {}interface IDerived : IBase {}class MyClass : IBase, IDerived {}
57+
``` cs
58+
interface IBase {}
59+
60+
interface IDerived : IBase {}
61+
62+
class MyClass : IBase, IDerived {}
5963
```
6064
6165
The compiler emits the implemented interfaces as `IDerived, IBase`. The ordering of interfaces is important when using the <xref:System.Runtime.InteropServices.ClassInterfaceAttribute> class with `[ClassInterface(ClassInterfaceType.None)]` to expose an explicit interface as the default interface. Regardless of the specified `ClassInterfaceType`, use the <xref:System.Runtime.InteropServices.ComDefaultInterfaceAttribute> attribute to specify which interface should be recognized as the default.

0 commit comments

Comments
 (0)