UiPath the DataTable and convert Array List

Today to share with you, how DataTable into List and Array, do this small U also spent a lot of time to study, and eventually found not so complicated.

First is that the difference between Array and List of:

List: just like a chain, space for storing data can not be continuous.

Array: Like a Execl in a column, but it would have to specify the size of the storage space at the time of the statement, in other words for words when the need is to declare the size of initialized data.

When will it use Array, List when to use it?

Summary 1: When we are not sure the size, it is best to use instead of Array List

Summary 2: When you need to find a large number of operations, it is best to use Array, with who knows who.

Summary 3: When the need for frequent insertions, deletions, it is best to use instead of Array List

Finally: As List need to store the address of his next node, so more space is wasted 

The following small U will explain to you how to convert, in this case Activity in use are:

  1. Execl Application Scope
  2. Read Range
  3. Output Data Table
  4. Write Line
  5. Log Message
  6. For Each Row
  7. Invoke Method --- used to convert List
  8. For Each
  9. Use --- into an array Assign

The whole process looks very long, the actual principle is very simple, please be patient and read the small partner

                       

(A) We take a look at how to output DataTable, this is actually very simple, direct a new OutputDataTable of activity on it

 

 Since my form there is no header row, so to get rid of the title

 

See, that is so simple, just remember that he is the contents inside the entire DataTable as a string output.

(B) how to convert DataTable to List it?

Started this problem has been not know, always thinking with ForEachRow read, then direct assignment, how the results will not work, but fortunately found a way can be achieved by Invoke Method in the Add, pay attention to the type definition List is List <String> and the need for handling new List (of string) in the Default

 

 

---------------------------update content--------------------- --------

When using Invoke Method, we need to set the parameters, as shown below

 

Parameter Description missing, many students are stuck here today into this additional

 

Printing is very simple, direct use of ForEach, note that not ForEachRow

 

 

(C) how to convert List to an array, this is also very simple

This is just one step, array of type String []

 

 Finally, we look at the output

 

Guess you like

Origin www.cnblogs.com/mynancy-android/p/11850560.html