programming-examples/c-sharp/Inheritance_&_Interface/C# Program to Demonstrate iList Interface.cs
2019-11-15 12:59:38 +01:00

42 lines
698 B
C#

/*
* C# Program to Demonstrate iList Interface
*/
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<int> list = new List<int>();
list.Add(5);
list.Add(7);
list.Add(9);
Display(list);
Console.ReadLine();
}
static void Display(IList<int> list)
{
Console.WriteLine("Count: {0}", list.Count);
foreach (int num in list)
{
Console.WriteLine(num);
}
}
}
/*
Count: 3
1
2
3
Count: 3
5
7
9