For Asp.net Training with C# Click Here
Written By:-Isha Malhotra
Email:-malhotra.isha3388@gmail.com
Can We inherit the interface into
another interface?
Yes we can
inherit the interface into another interface. It follows the same signature for
inheritance as we use to inherit the class like:-
1. Create first interface
using
System;
using System.Collections.Generic;
using
System.Linq;
using
System.Web;
public interface idef
{
int sum(int p, int q);
int mul(int p, int q);
}
2. Create 2nd interface and
inherit first interface idef into this.
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
public interface idef2 : idef
{
int div(int p, int q);
}
3. The class which implement the
interface idef2 will give the definition to all m
The all member of both interfaces.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
/// Summary description for Class2
/// </summary>
public class Class2: idef2
{
public int sum(int x, int y)
{
return x + y;
}
public int mul(int x, int y)
{
return x * y;
}
public int div(int x, int y)
{
return x / y;
}
}
No comments:
Post a Comment