Count: 3 1 2 3 Count: 3 5 7 9
Users Online
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Latest Articles
Articles Hierarchy
C# Program to Demonstrate the iList Interface
C# Program to Demonstrate the iList Interface
This is a C# Program to demonstrate iList interface.
This C# Program Demonstrates iList Interface.
Here Lists and arrays implement IList and this interface is an abstraction that allows list types to be used with through a single reference type. With it, we can create a single method to receive an int[] or a List.
Here is source code of the C# Program to Demonstrate iList Interface. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
/* * 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); } } }
This C# Program is used to demonstrate iList Interface. Lists and arrays implement IList. This interface is an abstraction that allows list types to be used with through a single reference type with it. Create a single method to receive an int[] or a List<int> the Add(Object) adds an item to the IList.
Here the lists and arrays implements IList. This interface is an abstraction that allows list types to be used with through a single reference type. With it, we can create a single method to receive an int[] or a List.