O'Reilly logo

Everyday Data Structures by William Smith

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Instantiating lists

Like other data structures, lists must be defined and instantiated prior to being used. Each of the four languages that we will examine in this text has varying support for, and unique implementations of, the list data structure. Let's briefly examine how to instantiate a list in each language.

C#

Instantiating lists in C# requires the use of the new keyword:

    //Array backed lists 
    ArrayList myArrayList = new ArrayList(); 
    List<string> myOtherArrayList = new List<string>(); 
 
    //Linked lists 
    LinkedList<string> myLinkedList = new LinkedList<string>(); 

The C# ArrayList class originated in .NET 1.0, and it is not used very often anymore. Most developers prefer to use the generic concrete implementation, List<of T>, for an array-based ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required