# List\<Type>

A list type is an object that can hold a list of other types. When you drag a list onto the canvas, you can populate it with a list of other types.

With a list type you can, for example, make a list of strings, a list of dates, a list of Types or of any other type Linx caters for.

***

### Properties <a href="#properties" id="properties"></a>

#### Type <a href="#type" id="type"></a>

Select the List element type, e.g. String, Bolean, Integer, List, etc

#### Value <a href="#value" id="value"></a>

The default value for the variable. This value can contain either Json or Xml.

You can paste a string in the *Value* property or use the List Editor to add items to your list.

![list](https://3338214469-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1nxDeDH8GVCXb0XelqGm%2Fuploads%2Fgit-blob-b577f0317cf64a1413ee4c354e4609be81dbcc65%2Flist.png?alt=media)

### List functions <a href="#list-functions" id="list-functions"></a>

#### All <a href="#all" id="all"></a>

Goes through the List and tests each element against a specific condition. If all of the items in the List satisfies the condition, then returns 'true'. If any item goes against the condition, then returns 'false'.

Returns: Boolean.

`[List].All([condition])`

Example:

```csharp
ListOfStrings.All(q => q.Length > 2)
ListOfPersons.All(person => person.Email.Length > 0)
```

#### Any <a href="#any" id="any"></a>

Determines whether a sequence contains any elements.

Syntax:

`[list].Any([(optional)condition])`

Examples:

```csharp
listOfCars.Any()

listOfPeople.Any(person => person.Name == "John")
```

#### Append <a href="#append" id="append"></a>

Returns a sequence that starts with the given sequence followed by the specified value.

Syntax:

> \[list].Append(\[element])

Example:

`ListOfPeople.Append(NewPerson)`

#### Average <a href="#average" id="average"></a>

Computes the average of a sequence of numeric values.

Syntax:

`[list].Average([(optional)selector])`

Examples:

```csharp
listOfNumbers.Average()

listOfPeople.Average(person => person.Age)
```

#### Concat <a href="#concat" id="concat"></a>

Joins 2 lists together by adding the second list to the end of the first list. The List types must be the same.

Returns: List. List will be of the same type as the original two, containing all the elements.

`[List].Concat([List])`

Example:

`List1.Concat(List2)`

#### Contains <a href="#contains" id="contains"></a>

Check whether an item exists inside of the list.

Returns: Boolean - 'true' if List contains the item, 'false' if List does not contain item.

`[List].Contains([Item])`

Example:

`List1.Contains("A")`

#### Count <a href="#count" id="count"></a>

Returns the number of elements in a sequence.

Syntax:

> \[list].Count(\[(optional)condition])

Examples:

```csharp
listOfCars.Count()

listOfPeople.Count(person => person.Name == "John")
```

#### ElementAt <a href="#elementat" id="elementat"></a>

Fetch an element at a specific index in the List. Important note, Lists in Linx are zero-indexed, which means the first element in the list is at index 0.

Returns: Generic. Will return the same type that the List is set as. If a List type is String, then ElementAt returns String, if List is a defined Type Person, then ElementAt returns a Person.

`[List].ElementAt([Integer])`

Example:

`List1.ElementAt(2)`

#### \[] (Square Brackets) <a href="#square-brackets" id="square-brackets"></a>

Fetch an element at a specific index in the List. Important note, Lists in Linx are zero-indexed, which means the first element in the list is at index 0.

Returns: Generic. Will return the same type that the List is set as. If a List type is String, then \[] returns String, if List is a defined Type Person, then \[] returns a Person.

`[List][[Integer]]`

Example:

`List1[2]`

#### ElementAtOrDefault <a href="#elementatordefault" id="elementatordefault"></a>

Fetch an element at a specific index in the List, however if the index is out of the List�s range, then returns a default (which is \<NULL> in most cases) without raising an exception.

*Important note:* Lists in Linx are zero-indexed, which means the first element in the list is at index 0.

Returns: Generic. Will return the same type that the List is set as. If a List type is String, then ElementAt returns String, if List is a defined Type Person, then ElementAt returns a Person.

If the index is out of the List�s range, return�s a \<NULL>

`[List].ElementAtOrDefault([Integer])`

Example:

`List1.ElementAtOrDefault(2)`

#### First <a href="#first" id="first"></a>

Fetch the first element in a List.

Returns: Generic. Will return the same type that the List is set as. If a List type is String, then First returns String, if List is a defined Type Person, then First returns a Person.

`[List].First()`

\[List].First(\[(optional)condition])

Example:

```csharp
List1.First()

ListOfPersons.First(person => person.Name == "John")
```

#### FirstOrDefault <a href="#firstordefault" id="firstordefault"></a>

Fetch the first element in a List. However, if the List is empty, returns a \<NULL> instead of raising an exception.

Returns: Generic. Will return the same type that the List is set as. If a List type is String, then FirstOrDefault returns String, if List is a defined Type Person, then FirstOrDefault returns a Person. If the List is empty, return�s a \<NULL>

`[List].FirstOrDefault()`

\[List].FirstOrDefault(\[(optional)condition])

Example:

```csharp
List1.FirstOrDefault()

ListOfPersons.FirstOrDefault(person => person.Name == "John")
```

#### Last <a href="#last" id="last"></a>

Fetch the last element in a List.

Returns: Generic. Will return the same type that the List is set as. If a List type is String, then Last returns String, if List is a defined Type Person, then Last returns a Person.

`[List].Last()`

\[List].Last(\[(optional)condition])

Example:

```csharp
List1.Last()

ListOfPersons.Last(person => person.Name == "John")
```

#### LastOrDefault <a href="#lastordefault" id="lastordefault"></a>

Fetch the last element in a List. However, if the List is empty, returns a \<NULL> instead of raising an exception.

Returns: Generic. Will return the same type that the List is set as. If a List type is String, then LastOrDefault returns String, if List is a defined Type Person, then LastOrDefault returns a Person. If the List is empty, return�s a \<NULL>

`[List].LastOrDefault()`

\[List].LastOrDefault(\[(optional)condition])

Example:

```csharp
List1.LastOrDefault()

ListOfPersons.LastOrDefault(person => person.Name == "John") 
```

#### Max <a href="#max" id="max"></a>

Returns the maximum value in a sequence of values.

Syntax:

`[list].Max([(optional)selector])`

Examples:

```csharp
listOfNumbers.Max()

listOfPeople.Max(person => person.Age)
```

#### Min <a href="#min" id="min"></a>

Returns the minimum value in a sequence of values.

Syntax:

`[list].Min([(optional)selector])`

Examples:

```csharp
listOfNumbers.Min()

listOfPeople.Min(person => person.Age)
```

#### OrderBy <a href="#orderby" id="orderby"></a>

Order a List using a specific property within the List in ascending order. For Simple types, like String, and Integer, you will still need to define the property to order by. For complex types, for instance, Person, you need to provide the property to order by, for example Name.

Returns: List\<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then OrderBy returns a List\<String>.

`[List].OrderBy([selector])`

Example:

```csharp
ListOfString.OrderBy(q => q)

ListOfPersons.OrderBy(person => person.Name)
```

#### OrderByDescending <a href="#orderbydescending" id="orderbydescending"></a>

Order a List using a specific property within the List in descending order. For Simple types, like String, and Integer, you will still need to define the property to order by. For complex types, for instance, Person, you need to provide the property to order by, for example Name.

Returns: List\<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then OrderBy returns a List\<String>.

`[List].OrderByDescending([selector])`

Example:

```csharp
ListOfString.OrderByDescending(q => q)

ListOfPersons.OrderByDescending(person => person.Name)
```

#### Single <a href="#single" id="single"></a>

Provides the only item in a List. If a list contains no items or more than one, an exception is thrown.

Returns: Generic. Will return the same type that the List is set as. If a List type is String, then Single returns String, if List is a defined Type Person, then Single returns a Person.

`[List].Single()`

\[List].Single(\[(optional)condition])

Example:

```csharp
List1.Single()

ListOfPersons.Single(person => person.Name == "John")
```

#### SingleOrDefault <a href="#singleordefault" id="singleordefault"></a>

Provides the only item in a List. Returns if the list contains no items, or throws an exception if it contains more than one item.

Returns: Generic. Will return the same type that the List is set as. If a List type is String, then Single returns String, if List is a defined Type Person, then Single returns a Person.

`[List].SingleOrDefault()`

\[List].SingleOrDefault(\[(optional)condition])

Example:

```csharp
List1.SingleOrDefault()

ListOfPersons.SingleOrDefault(person => person.Name == "John")
```

#### Skip <a href="#skip" id="skip"></a>

Provides a List where the first number of items are removed. You provide a number of items to skip.

Returns: List\<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then Skip returns a List\<String>.

`[List].Skip([Integer])`

Example:

`List1.Skip(5)`

#### SkipWhile <a href="#skipwhile" id="skipwhile"></a>

Provides a sequence that discards items as long as a specified condition is 'true' and then returns the remaining items.

Returns: List\<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then SkipWhile returns a List\<String>.

`[List].SkipWhile([condition])`

Example:

```csharp
ListOfStrings.SkipWhile(q => q == "A")

ListOfPersons.SkipWhile(person => person.Name == "John")
```

#### Sum <a href="#sum" id="sum"></a>

Computes the sum of a sequence of numeric values.

Syntax:

`[list].Sum([(optional)selector])`

Examples:

```csharp
listOfNumbers.Sum()

listOfPeople.Sum(person => person.Age)
```

#### Take <a href="#take" id="take"></a>

Provides a List of only the first number of items. You provide a number of items to take.

Returns: List\<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then Take returns a List\<String>.

`[List].Take([Integer])`

Example:

`List1.Take(5)`

#### TakeWhile <a href="#takewhile" id="takewhile"></a>

Provides a sequence that relays items as long as a specified condition is 'true' and then discards the remaining items.

Returns: List\<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then TakeWhile returns a List\<String>.

`[List].TakeWhile([condition])`

Example:

```csharp
ListOfStrings.TakeWhile(q => q == "A")

ListOfPersons.TakeWhile(person => person.Name == "John")
```

#### Where <a href="#where" id="where"></a>

Goes through the List and tests each element against a specific condition, and only taking the elements which satisfies the condition.

Returns: List\<Generic>. Will return a List of the same type as the original. For instance if the original List was a List of Strings, then TakeWhile returns a List\<String>.

`[List].Where([condition])`

Example:

```csharp
ListOfStrings.Where(q => q.Length > 2)

ListOfPersons.Where(person => person.Name.Length < 5)
```

### Links <a href="#links" id="links"></a>

Functions that can be performed in the Expression Editor

Use the AddToList function to append values to your list dynamically.

Use the ClearList function to remove all values from a list.
