- What is an Array?
An array is a variable that can store multiple values of the same data type.
Note that you cannot combine values of different data types in a single array.
- Usage Examples of Arrays Creating an Array
- Display the Variables panel.
- Create a new variable (here, we set the variable name to arrTest).
- Select "Array of [T]" as the variable type.
- A popup will appear, so click the dropdown.
- Select "String" for this example.
- Confirm that the variable type is set to String[].
By following the above steps, you can create an array of type String.
<Setting Initial Values for an Array>
By setting values such as {"ValueA", "ValueB", "ValueC", "ValueD", "ValueE"} in the default value of the Variables panel, you can set initial values for the array.
For the previously created arrTest variable, enter {"aaa", "bbb", "ccc"} in the default value of the Variables panel.
<Using Values Set in an Array>
The values "aaa", "bbb", and "ccc" set in the array can be accessed as arrTest(0), arrTest(1), and arrTest(2) respectively.
*Note: Arrays are counted starting from 0.
By setting a number inside the parentheses, you can use the corresponding value.
Set the following value in the "Message Box" activity:
- "Number 1:" + arrTest(0) + "/Number 2:" + arrTest(1) + "/Number 3:" + arrTest(2)
Click "Home > Start" or press the "F5" key to execute. When executed, the values set in the array will be reflected in the message as shown in the image.
<Changing Values in an Array>
Place the "Assign" activity above the message box.
As shown in the next image, set the left side of the assign activity to the location in the array you want to change, and the right side to the value you want to change to. Here, set the left side to arrTest(1) and the right side to "ddd".
Click "Home > Start" or press the "F5" key to execute. When executed, the second value will change from "bbb" to "ddd".
3. Functions for Manipulating Arrays
<IndexOf Function>
When the size of an array grows, you may know the value you want to retrieve but not its position in the array. The IndexOf function can retrieve the corresponding index by setting the array and value.
Set values in the function as follows:
- array.IndexOf(Array, Value)
For example, to get the index corresponding to the value "ccc" from the array arrTest, set it as follows:
- array.IndexOf(arrTest, "ccc")
Next, place a "Message Box" activity and set the following value in the "Text" property to check which index "ccc" is stored at in the array
*Since the value obtained by the IndexOf function is of type Int32, you need to add .ToString to display it in the message box, converting it to String type.
- array.IndexOf(arrTest, "ccc").ToString
When you execute the workflow, the value stored in the array will be displayed. Click "OK," and the index "2" corresponding to "ccc" will be shown as a message on the screen.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article