An interface contains only the signatures of methods, delegates or events. The implementation of the methods is done in the class that implements the interface, as shown in the following example:
interface ISampleInterface
{
void SampleMethod();
}
class ImplementationClass : ISampleInterface
{
// Explicit interface member implementation:
void ISampleInterface.SampleMethod()
{
// Method implementation.
}
static void Main()
{
// Declare an interface instance.
ISampleInterface obj = new ImplementationClass();
// Call the member.
obj.SampleMethod();
}
}
An interface can be a member of a namespace or a class and can contain signatures of the following members:
Methods
Properties
Indexers
Events
An interface can inherit from one or more base interfaces.
When a base type list contains a base class and interfaces, the base class must come first in the list.
A class that implements an interface can explicitly implement members of that interface. An explicitly implemented member cannot be accessed through a class instance, but only through an instance of the interface
--
You received this message because you are subscribed to the Google Groups "St.Mary's PG college MCA Major's - 2000" group.
To post to this group, send email to st_marys_m...@googlegroups.com.
To unsubscribe from this group, send email to st_marys_majors_...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/st_marys_majors_2000?hl=en.