We can determine whether a particular interface is implemented in a class by using is and as operators. The is operator enables you to check whether one type or class is compatible with another type or class; it returns a Boolean value.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
interface inter
{
bool show();
}
interface inter1
{
bool display();
}
class combineinter : inter
{
public bool show()
{
System.Console.WriteLine("show() method implemented");
System.Console.ReadLine();
return true;
}
}
static void Main(string[] args)
{
combineinter interp = new combineinter();
interp.show();
inter1 id=interp as inter1;
if(null!=id)
{
bool ok = id.display();
System.Console.WriteLine("Method Implemented");
System.Console.ReadLine();
}
else
{
System.Console.WriteLine("Method not imlemented");
System.Console.ReadLine();
}
}
}
}
OUTPUT
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
interface inter
{
bool show();
}
interface inter1
{
bool display();
}
class combineinter : inter
{
public bool show()
{
System.Console.WriteLine("show() method implemented");
System.Console.ReadLine();
return true;
}
}
static void Main(string[] args)
{
combineinter interp = new combineinter();
interp.show();
inter1 id=interp as inter1;
if(null!=id)
{
bool ok = id.display();
System.Console.WriteLine("Method Implemented");
System.Console.ReadLine();
}
else
{
System.Console.WriteLine("Method not imlemented");
System.Console.ReadLine();
}
}
}
}
OUTPUT