Maha

Maha

  • NA
  • 0
  • 324.8k

Interface

Aug 23 2012 6:03 PM
This program is given in the following website (http://www.developer.com/net/csharp/article.php/1482651/Working-with-Interfaces-in-C.htm) Listing 3.

In the program if(inter is Interdemo1) is false.

Is there any possible modification to make if(inter is Interdemo1) is true. Code is highlighted

using System;

interface Interdemo
{
bool Show();
}

interface Interdemo1
{
bool Display();
}

class Interimp : Interdemo
{
public bool Show()
{
Console.WriteLine("Show() method Implemented");
return true;
}

public static void Main(string[] args)
{
Interimp inter = new Interimp();
inter.Show();

if (inter is Interdemo1)
{
Interdemo1 id = (Interdemo1)inter;
bool ok = id.Display();
Console.WriteLine("Method Implemented");
}

else
{
Console.WriteLine("Method not implemented");
}
Console.ReadKey();
}
}

Answers (2)