List:
- Auto resizing
- Type safe
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace GenericList
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> list = new List<int>();
- list.Add(10);
- list.Add(20);
- list.Add(23);
- list.Add(33);
- print(list);
- list.Insert(2,55);
- list.Insert(3,99);
- print(list);
- list.RemoveAt(1);
- print(list);
- Console.WriteLine("Size of list: "+list.Count);
- Console.ReadLine();
- }
- public static void print(List<int>list) {
- Console.WriteLine("Elements exists in the list:");
- foreach (int i in list)
- Console.WriteLine(i);
- }
- }
- }
0 Comments:
Post a Comment