Showing posts with label c sharp tutorial. Show all posts
Showing posts with label c sharp tutorial. Show all posts

Sunday, 29 December 2013

IEnumerator and IEnumerable Interface

IEnumerator and IEnumerable Interface

In simple term collection in C# is a way to store objects. We use System.Collection namespace to work with collection.

IEnumerator and IEnumerable

In collection we are able to access the each element using Enumerator. There is an Interface IEnumerator which contains the following method and properties:-

namespace System.Collections
{
    public interface IEnumerator
    {
    

Sunday, 30 June 2013

Interface in Detail with example of runtime polymorphism

Interface in Detail

Interface in C# is basically a contract in which we declare only signature. The class which implemented this interface will define these signatures. Interface is also a way to achieve runtime polymorphism. We can add method, event, properties and indexers in interface

Syntax of Interface

We declare interface by using the keyword interface which is as follows:-

public interface interface_name
{

    //here we define our signature

}

For Example:-

Create an interface and add some signature of method

public interface Idef1
{
    //singnature of methods

    int sum(int x, int y);
    int mul(int x, int y);

}