C# Type IsInterface
Description
Type IsInterface
gets a value indicating whether the
Type is an interface; that is, not a class or a value type.
Syntax
Type.IsInterface
has the following syntax.
public bool IsInterface { get; }
Example
The following example creates an interface, checks for the interface type, and indicates whether a class has the IsInterface property set.
using System;/*from ww w . j a v a 2 s.c om*/
// Declare an interface.
interface myIFace
{
}
class MyIsInterface
{
public static void Main(string []args)
{
try
{
Console.WriteLine(typeof(myIFace).IsInterface);
Console.WriteLine(typeof(MyIsInterface).IsInterface);
}
catch(Exception e)
{
Console.WriteLine("\nAn exception occurred: {0}.", e.Message);
}
}
}
The code above generates the following result.