Wednesday, 19 June 2013

what is an interface, interface in C#

what is an interface :-
Interface is a contract that defines the signature of the functionality its looks like a class but has no implementation. It has only empty defination of methods, functios, events, and indexer.

Interfaces provide forced implementation . for instance in the below code snippet we have created a simple interface called as  IDbCompulsory. the below classes who
implement interface "IDbCompulsory" has to provide implementation for ExecSql


The below is an example

interface IDbcompulsory
{
       void ExecSql();
}

public class Sqlserver : IDbcompulsory
{
      public void ExecSql()
      { 
           // here code for firing Sql server Sql statements;
           // are written;
      }
}

public class Oracle : IDbCompulsory
{
      public void ExecSql()
      {
           // Here code for firing Oracle Sql Statements;
           // are written
       }
}

0 comments:

Post a Comment