---
title: "Discussion on \"To test if object implements interface in C# - \nPattern matching overview\" | Hashnode"
description: "Discussion on \"To test if object implements interface in C# - \nPattern matching overview\". Is there anyway of testing if an object implements a given interface in C#?\nSolution:\n\n\nSolution 1:If you want to use the typecasted object after the check:Since C# 7.0:\nif (obj is IMyInterface myObj)\nThis is the same as\nIMyInterface myObj = obj as I..."
url: "https://hashnode.com/posts/to-test-if-object-implements-interface-in-c-pattern-matching-overview/611be0588b9c03054649ef46"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [To test if object implements interface in C# - Pattern matching overview](https://dheerajchopra.hashnode.dev/to-test-if-object-implements-interface-in-c-pattern-matching-overview?utm_source=hashnode&utm_medium=feed)

Is there anyway of testing if an object implements a given interface in C#? Solution: Solution 1:If you want to use the typecasted object after the check:Since C# 7.0: if (obj is IMyInterface myObj) This is the same as IMyInterface myObj = obj as I...

Aug 17, 2021 · 1 min read · dheerajchopra.hashnode.dev  
Read the article

-   [#aspnet](https://hashnode.com/tag/aspnet)
-   [#csharp](https://hashnode.com/tag/csharp)
-   [#object-oriented-programming](https://hashnode.com/tag/object-oriented-programming)
-   [#object](https://hashnode.com/tag/object)
-   [#solid-principles](https://hashnode.com/tag/solid-principles)

## Written by

[Dheeraj Chopra](https://hashnode.com/@DheerajChopra)

@DheerajChopra

  
[View profile](https://hashnode.com/@DheerajChopra)

Write Technical Blogs Related To - Asp.Net Core | Javascript | Azure

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
