WHAT IS THE EXACT USE OF INTERFACE(DONT TELL USE FOR
MULTIPLE INHERITANCE)

Answer Posted / arvind nagar

Interface is mainly use to apply restrictions in accesing
the members.
For eg.-
using System;
Interface Sales
{
Void prediction();
}
Interface Hr
{
Void SalayInfo();
}
Class Abc:Sales,Hr
{
Public void Pediction()
{
x.WriteLine("Sales for 2008 will 2000 laptops");
}
Public void SalryInfo()
{
x.WriteLine("Salary is going to increment by 30%");
}
Public void Hello()
{
x.WriteLine("Hello frnds");
}
}
class test
{
public static void main()
{
Hr a= new Abc();
a.SalaryInfo();
}
}

O/p-- Salary is going to increment by 30%.
Suppose we wish to access the Hello() function, then we
can't access the a.Hello();--it gives error.
b'coz Hr doesn't contain a
definition of Hello.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is semaphore in c#?

506


When a switch is said to be congested?

576


Are c# tuples immutable?

505


What is the default value of string in c#?

555


What is difference between internal and protected internal in c#?

456






Why References are stored on heap and variables on stack?

497


Why do we need structs in c#?

444


What is an int c#?

476


What is instantiating a class?

508


What is regex replace in c#?

502


How to find methods of a assembly file (not using ILDASM)?

633


What is system console writeline in c#?

465


Why singleton pattern is used in c#?

532


Why static constructor is parameterless in c#?

591


Does c# support c type macros?

551