C# Program to Check a Specified Type Is an Interface or Not

Today we are going to discuss this important topic via this article C# Program to Check a Specified Type Is an Interface or Not. We hope you like this article.

C# Program to Check a Specified Type Is an Interface or Not

C# Program to Check a Specified Type Is an Interface or Not

//C# program to check a specified type 
//is an interface or not.

using System;
using System.Reflection;

interface Inf
{
    void Print();
}
class Program
{
    static void Main()
    {
        Type type = typeof(Inf);

        if (type.IsInterface== true)
        {
            Console.WriteLine("Inf is an interface");
        }
        else
        {
            Console.WriteLine("Inf is not an interface");
        }
    }
}
Inf is an interface
Press any key to continue . . .

Final Words

C# Program to Check a Specified Type Is an Interface or Not We learned about this very clearly through this article. And if you liked this article please share it with your friend.

Hi, I'm Selva a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment