Skip to content

What is the best way to match a specific member implementation (on a class) with the corresponding member of an interface? #907

Discussion options

You must be logged in to vote

Look at the generated IL:

.method public final specialname newslot strict virtual 
    instance string get_AlternativeNamedProperty () cil managed 
{
    .override method instance string ISimpleInterface::get_BasicProperty()

    // ...
}

The property getter and setter are methods with an explicit .override clause. You'll find those in the MethodDefinition.Overrides collection.

Note that no .override clause needs to be present when the method signatures match (implicit implementation).

By the way:

This isn't an issue for assemblies created from C# because the class member names must match the names of the interface members.

C# has explicit interface implementations, which produce simil…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@e-manual-goldstein
Comment options

@e-manual-goldstein
Comment options

@ltrzesniewski
Comment options

Answer selected by e-manual-goldstein
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants