Skip to main content

Posts

Showing posts with the label asp.net interface

How to use interfaces in dotnet

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: 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(); }