What is Interface? Explain with an example.
Answers were Sorted based on User's Feedback
Answer / senthil
An Interface is a reference type and it contains only
abstract members. the interface contains only declaration
for its members. Any implementation must be placed in class
that realizes them. Interface's members can be Events,
Methods, Properties and Indexers. But
| Is This Answer Correct ? | 44 Yes | 5 No |
Answer / krishnaveni.k
An Interface is a reference type. In C# and java not
support the multiple inheritance so i am using interface
concept.A class can implement multiple interfaces and using
interface keyword.It contain only method declaretion. but
not implementaion
| Is This Answer Correct ? | 20 Yes | 5 No |
Answer / mahesh
It contains only Function Prototype (Function Declaration)
| Is This Answer Correct ? | 16 Yes | 11 No |
Answer / dharmendra kumar
Interface is a syntactical contract that all the derived
classes should follow.
public interface MotorStateObject
{
int State{ get;}
void Running();
void Stop();
int Speed { set;get; }
}
public class Car : MotorStateObject
{ .....
}
public class Bike : MotorStateObject
{......
}
public class Bus : MotorStateObject
{......
}
public class MotorState()
{
public void applybrake(MotorStateObject Object)
{
MotorStateObject.Stop();
}
}
| Is This Answer Correct ? | 5 Yes | 1 No |
Answer / srinivasa reddy
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace InterfaceExample
{
interface IA
{
void MethodA();
}
class Program : IA
{
static void Main(string[] args)
{
IA InterfaceA = new Program();
InterfaceA.MethodA();
Console.ReadKey();
}
void IA.MethodA()
{
Console.WriteLine("This is a test");
}
}
}
| Is This Answer Correct ? | 6 Yes | 4 No |
Answer / radhika
An interface defines a contract for a class.The name of an
interface begins with a capital I.interface doesnot
contains any method implementations.The class that
implements the interface must provide all the
implementation for the members defined in that interface.
| Is This Answer Correct ? | 4 Yes | 2 No |
Answer / mohit bhandari
An interface is a named set of method signatures.Interfaces
can also define events and properties because all of these
are just syntax shorthands that map to methods anyway.
In C#, interface keyword is used to define an interface,
giving it a name and its set of instance method signatures.
e.g.
public interface IDisposable {
void Dispose();
}
| Is This Answer Correct ? | 2 Yes | 2 No |
Answer / lakshman
interface is a collection of abstract members i.e semi implementation block..interface is used to implement the of multiple inheritance
| Is This Answer Correct ? | 0 Yes | 0 No |
HOw to judge a person for a team if you are allowed to ask only 2 questions to him?
what is method overloading in c#?
What is wcf c#?
Where do I put dll files?
What are c# attributes and its significance?
Define a partial class?
What are the 2 kinds of data type conversions in c#?
What is event sourcing in c#?
how to Create a datagridview control with check box column with 8rows in it, the maximum number of check boxes checked should be 3, when user checks the 4th corresponding message should be displayed and check box should be checked. User can uncheck the checked boxes Note: read-only property should not be used
Can arraylist hold primitive types?
How do you prevent a class from being inherited?
What is a deadlock lock?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)