Monday, 8 February 2016

C# Program how to Demonstrate iList Interface

using System;
using System.Collections.Generic;

class Interface
{
    static void Main()
    {
        int[] a = new int[3];
        a[0] = 10;
        a[1] = 20;
        a[2] = 30;
        DisplayResult (a);

        List<int> list = new List<int>();
        list.Add(50);
        list.Add(70);
        list.Add(90);
        DisplayResult (list);
        Console.ReadLine();
    }

    static void DisplayResult (IList<int> list)
    {
        Console.WriteLine("Count: {0}", list.Count);
        foreach (int number in list)
        {
            Console.WriteLine(number);
        }
    }
}
--------------------
OUTPUT:- 
Count: 3
10
20
30
Count: 3
50
70

90
------------------------------

No comments:

Post a Comment