List in C#

Here i am going to explain what is list in C#.
  • 2403
Introduction

List in C# provide a strongly typed list of objects . These objects in list can be searched by objects. There ere many methods in list that provide feature like sorting, searching and manipulating. In list we can resize it dynamically.

Some methods in List

  • ForEach
  • GetEnumerator
  • GetHashCode
  • GetRange
  • GetType
  • IndexOf(T)
  • IndexOf(T, Int32)
  • IndexOf(T, Int32, Int32)
  • Insert
  • InsertRange

Example

using System;
using
 System.Collections.Generic;
using
 System.Linq;
using
 System.Text;
 

namespace
 ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> colorList = new List<string>();
            colorList.Add("Red");
            colorList.Add("Green");
            colorList.Add("Pink");
            colorList.Add("Blue");
            colorList.Add("Black");
 
            foreach (string color in colorList)
            {
                Console.WriteLine(color);
                Console.ReadLine(); 
            }
        }
    }
}

Output

Clipboard02 (1).jpg
 

 

  
© 2019 DotNetHeaven. All rights reserved.