How to create List in C#

In this article I will explain how can we create the list in C#.
  • 3234

Introduction

In this article I will explain the list in C#. List can be used to store the data. For this we use the System.Generic namespaces.

Example,

namespace ConsoleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            List<int> list1 = new List<int>();

            list1.Add(11);

            list1.Add(12);

            list1.Add(13);

            list1.Add(14);

            Console.WriteLine("The list is as:");

            foreach (int i in list1)

            {

                Console.WriteLine(i);

            }

        }

    }

}

 

Output

list.jpg 

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2018 DotNetHeaven. All rights reserved.