mercredi 30 août 2017

C# Reflection test if member is an interface implementation

Suppose I have the following interface and implementing class:

public interface IInterface
{
    string MyMember { get; }
}

public class Class : IInterface
{
    public string MyMember
    {
        get
        {
            return "foo";
        }
    }
}

Now I get the member via reflection

var member = typeof(Class).GetMember("MyMember").Single();

How can I test if the member is the implementation of an interface?





Aucun commentaire:

Enregistrer un commentaire