Simple List Example

Rajesh_Kumar
Posted by Rajesh_Kumar under C# category on | Points: 40 | Views : 551
First of all import System.Collections.Generic Namespace at the top of the Page or Form.

using System.Collections.Generic;

List<string> lst_courses = new List<string>();
lst_courses.Add("C#");
lst_courses.Add("VB.Net");
lst_courses.Add("ASP.NET");
lst_courses.Add("SQL-Server");

//now loop through the items of list collection
foreach(string items in lst_courses)
{
Console.WriteLine(items);
}


Output:
C#
VB.Net
ASP.NET
SQL-Server

Comments or Responses

Login to post response