Monday, February 15, 2021

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

No comments:

Post a Comment

Popular Posts