---
title: "Use Reflection to find Methods that implement explicit interfaces"
url: "https://osherove.com/blog/2008/10/15/use-reflection-to-find-methods-that-implement-explicit-inter.md"
canonical: "https://osherove.com/blog/2008/10/15/use-reflection-to-find-methods-that-implement-explicit-inter.html"
published: "2008-10-15T07:11:40"
updated: "2008-10-15T07:11:40"
tags: [".NET"]
author: "Roy Osherove"
description: "update: added a check for IsPrivate based on the comments. so I won't forget: here's how you can iterate over a type definition's methods and see if one of them is an explicit intreface definition: foreach (var info in…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Use Reflection to find Methods that implement explicit interfaces

By Roy Osherove October 15, 2008 In [.NET](https://osherove.com/blog/category/net)

**Historical article** · Originally published October 15, 2008; technical details may be outdated.

update: added a check for IsPrivate based on the comments.

so I won't forget: here's how you can iterate over a type definition's methods and see if one of them is an explicit intreface definition:

```
foreach (var info in GetType().GetMethods(
         BindingFlags.NonPublic|BindingFlags.Instance|BindingFlags.DeclaredOnly))
  {
   if (info.IsFinal && info.IsPrivate)
   {
         Console.WriteLine("Explicit interface implementation: {0}", info.Name);
   }
  }
```

this will show only the "Write" method for the following class:

```
public class Class1 : ILogger
{
public void show()
{
} 
void MyMethod()
{
}
void ILogger.Write(string s)
{
}
}
```

## More in .NET

[All posts in .NET](https://osherove.com/blog/category/net)

- Nov 2, 2008

    ### [Isolator Feature Focus: Duck Typing and Isolate.Swap](https://osherove.com/blog/2008/11/2/isolator-feature-focus-duck-typing-and-isolateswap.html)

- Oct 28, 2008

    ### [PDC 2008 Videos](https://osherove.com/blog/2008/10/28/pdc-2008-videos.html)

- Oct 12, 2008

    ### [SharpMock 0.1 ?](https://osherove.com/blog/2008/10/12/sharpmock-01.html)

- Oct 11, 2008

    ### [Isolator feature focus – Advanced Debugger Support for fakes](https://osherove.com/blog/2008/10/11/isolator-feature-focus-advanced-debugger-support-for-fakes.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
