Monday, 6 February 2012

What is Interface Can you say Example?


Yes,Interface is also one type like class but it is not class.Interface are used make standardization,decoupling,dynamic polymorphim.
Interface considerations:
Interface contains only declarations it doesn’t contain any deifications.
Interface members are by default à abstract members, as well as public members.
Interface doesn’t contain any fields.
Interface members should implement in derived classes.
Ex:    public interface ICollection : IEnumerable
    {
        int Count { get; } // Returns the number of elements contained in the
      
    }
                               ICollection
                                
                           ArrayList :   ICollection
                           SortedList:  ICollection
                           Hashtable:  ICollection....................ect collections implement in their body definifications.
Like ArrayList, SortedList, Hashtable…ect collections implements the ICollection Interface.
Like Arraylist
class ArrayList : IList, ICollection, IEnumerable, ICloneable
    {
    public virtual int Count { get; } // Implemented here
}
Like the same way in the remaining collections SortedList,Hashtable..ect implements
    



From above example undersatand things
1.  Making Standarization--->Count
2.  Dynamic Loading---->As per Collection object

No comments:

Post a Comment