TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Lalit Raghav
622
1.4k
93.7k
Interface use
May 6 2015 2:28 AM
namespace InterFaceDemo
{
//defining First interface
interface ISum
{
void sum(int a, int b);
}
//defining second interface which inherits first interface
interface ISubtract:ISum
{
void sub(int a, int b);
}
//defining class which inherits second interface
class NewClass : ISubtract
{
//implementing interface defined methods
public void sum(int a, int b)
{
Console.WriteLine((a+b).ToString());
}
public void sub(int a, int b)
{
Console.WriteLine((a-b).ToString());
}
}
class Program
{
static void Main(string[] args)
{
//creating instance of class
NewClass newclass = new NewClass();
//calling sum() of ISum interface
newclass.sum(4,5);
//calling sub() of ISubtract interface
newclass.sub(5,8);
}
}
}
here i want to know that we have use interface .But we can call add and subtract method with out use interface.then what is need of interface .
Reply
Answers (
1
)
how to store array values in local drive using C#?
Rolling Dice Game