Monday, October 12, 2009

Interface in .NET

What is Interface?
          Interface is a Collection of abstract methods, members encapsulated together into a specific functionality. It contains only the signature of the members. The implementation of these members will be available on the class that implements the interface

Interface can be a member of class or namespace and it contains only the signature of following members
   1. Methods
   2. Properties
   3. Indexers
   4. Events or Delegates

When you go for Interface?
          C# doesn’t support Multiple Inheritance. To overcome these problems we can use Interface. Also interface provides more design facility. Interface let you separate the definition of the object from their implementation. Also there are several others reason like,
   1. your application may requires many unrelated object types to provide certain functionality
   2. it is more flexible than base class
   3. you don’t need to inherit implementation from base class
   4. it is very useful when you can’t use class inheritance where as structure can’t inherit from class but it can be implemented thru interface

No comments:

Post a Comment