Skip to main content

List DataType - #albacktobasics.

Hi Readers,

Hope you all are doing great. Thankyou for all your love and support with great questions and discussions.

In this article we will talk about a New Datatype available in AL that was discussed in last #bcopendiscussion.

Question - What is List Data Type and How to Use It?

We will discuss in details about List Datatype. #albacktobasics

Available from AL runtime version 1.0.

What is List?

  • List Represents a strongly typed list of ordered objects that can be accessed by index. 

How List is Different From Array?

  • Contrary to the Array data type, a List is unbounded, such that its dimension does not need to be specified upon declaration.

Method with List?

  • Insert - Inserts an element into the List at the specified index.
  • Add - Adds a value to the end of the List.
  • AddRange - Adds the elements of the specified collection to the end of the list.
  • Count - Gets the number of elements contained in the List.
  • LastIndexOf - Searches for the specified value and returns the one-based index of the last occurrence within the entire List.
  • Reverse - Reverses the order of the elements in the entire List.
  • Contains - Determines whether an element is in the List.
  • Set - Sets the element at the specified index.
  • Get - Gets the element at the specified index.
  • GetRange - Get a shallow copy of a range of elements in the source.
  • Remove - Removes the first occurrence of a specified value from the List.
  • RemoveAt - Removes the element at the specified index of the List.
  • RemoveRange - Removes a range of elements from the List.

Remember - 

  • The List can only be used with simple types i.e. you can have a List of [Integer]. 
  • We cannot have a List of [Blob]. 
  • List data type does not support holding instantiated records. 
  • Lists are 1-based indexed, that is, the indexing of a List begins with 1.

Example Code - 


Example Output - 


In Next article, We will see an example of how to use List with an extension scenario.

If you have any other basic stuff that you would like to discuss please let me know and I will try to write an article on this.

Let me know your views as comment to this article.

Regards,
Saurav Dhyani

www.sauravdhyani.com
#albacktobasics

Comments

Popular posts from this blog

VIEW SERVER STATE permission on SQL Server?

Hi all, Sometime While trying to Login into a database we face an error message as shown below. --------------------------- Microsoft Dynamics NAV Classic --------------------------- You cannot start Microsoft Dynamics NAV Classic because you do not have the VIEW SERVER STATE permission on SQL Server. Contact your system administrator. --------------------------- OK    ---------------------------

RTC Report It is not possible to instantiate the Visual Studio bridge.

Hi all, As a Navision developers I have Multiple Versions of Navision running in single Machine. As discussed Earlier in the post how to run multiple Version of RTC in single machine. So my machine have following details for RTC Versions - NAV 2009 R2    - is installed. NAV 2009 SP1  - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 SP1 IN\ NAV 2009         - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 IN\ This approach has been working great for execution of Classic and RTC Clients. However, after installing Dynamics NAV 2009 R2, if i tried to view the Layout for an NAV 2009 SP1 Report i was getting the following error: ---------------------------  Microsoft Dynamics NAV Classic  ---------------------------  It is not possible to instantiate  the Visual Studio bridge.  ---------------------------  OK    --------------------------- After searchi...

NAV 2013 R2 - Cumulative update 12 Released.

Hi all, Please find below the details of  Cumulative Update 12 released for Microsoft Dynamics NAV 2013 R2. Title - Cumulative Update 12 for Microsoft Dynamics NAV 2013 R2 Build No. - 38053 Release Date - October, 2014 Local Version Included - AU, AT, BE, CH, DE, DK, ES, FI, FR, IS, IT, NA, NL, NO, NZ, SE, UK, RU Download Link Note: Implementing this cumulative update will require a database conversion unless you have already implemented update rollup 5.