Sunday, 3 December 2017

C# Program to Demonstrate iList Interface


Code:

using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        int[] a = new int[3];
        a[0] = 1;
        a[1] = 2;
        a[2] = 3;
        Display(a);

        List list = new List();
        list.Add(5);
        list.Add(7);
        list.Add(9);
        Display(list);
        Console.ReadLine();
    }

    static void Display(IList list)
    {
        Console.WriteLine("Count: {0}", list.Count);
        foreach (int num in list)
        {
            Console.WriteLine(num);
        }
    }
}


Output:

Count: 3
1
2
3
Count: 3
5
7
9


More C# Programs:

















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...