How to use interfaces in .Net
An interfaces contains only the signatures of methods.The implementation of the methods is done in the class that implements the interface.
SYNTAX:
Example:
=======
interfaces contains only contains only abstract methods ,hence it is fully abstract.
Interface supports a structure like multiple inheritance.
Interfaces are not initialized but the references will be created.
An interfaces contains only the signatures of methods.The implementation of the methods is done in the class that implements the interface.
SYNTAX:
interface interface_name
{
void method1()
void method2()
}
By default all the methods in interfaces are fully "public abstract"Example:
=======
interface inter1
{
void getdata();
void putdata();
}
class sample1:inter1
{
int eno;
string ename;
{
public void getdata()
{
console.writeline("enter employee number");
eno=int.parse(console.readline());
console.writeline("enter employee name");
ename=console.readline();
}
public void putdata()
{
console.writeline("employee number:"+eno);
console.writeline("employee name:"+ename);
}
}
class class1
{
static void main ()
{
sample1 obj=new sample1();
obj.getdata();
console,.writeline();
obj.putdata();
}
}
}
interfaces contains only contains only abstract methods ,hence it is fully abstract.
Interface supports a structure like multiple inheritance.
Interfaces are not initialized but the references will be created.