Asp.net programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this Asp.net and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Asp.net Website by URL, How to Play YouTube Videos in Asp.net by using Jquery , Jquery Change div background on mouseover in asp.net , JQuery UI Datepicker (Calendar) etc.

Tuesday, August 18, 2015

What is Interface, how to use interface in C#

What is Interface, how to use interface in C#:


For resolve the problem of multiple inheritances, in C# introduce the concept of interface. Interface is a reference type and it contains only abstract method.  Interface member’s can be Events, Methods, Properties, and Indexers. The can only declaration of these members, as like class interface do not provide implementations.  The interface cannot contain data-field, constructor  constants, destructor and static members.

Syntax of interface in C#:

Interface <name of interface>
{
//user code……….
}



Implementation of interface in C#:

The general form of class that implements the inheritance is –
Class <class_name> : <interface_name>
{
}
When we want to implement more the one interface in C# the we can be using coma(,) between to interface when inherit in class as like:-
  Class <class_name> : <interface_name>,<interface2_name>
{
}

Example of interface in C#:

Using System;
Interface myinterface
{
Void show();
}
// interface end.
Class example:myinterface
{
Public void show()
{
Console.writeLine(“hello: I am method of interface”);
}
Public static void main(String [] args)
{
Example e=new example();
e.show();
}
}


Other Post Related to Asp.net and C#:





No comments:

Post a Comment