Self_solved:辞書変数dictの1行をDataRow配列arr_DataRowに変換したい

こんにちは
UiPath Studio 2025.0.161 Community editionのユーザです。

ForEachアクティビティで、辞書変数dictをkvをkeyにして回しています。

dictの変数の型はDictionary<String,DataRow□>です。

dictの1行をDataRow配列arr_DataRowに変換する構文が下図のとおり静的エラーを起こしています。
どう修正すればよいでしょうか?

Hi @gorby

You are using a For Each on dict variable. So where is kv coming from?

Hi @gorby

Can you try the following:

Approach 1:

arr_dataRow = New System.Data.DataRow() { currentKeyValuePairOfTextAndDataRow.Value }

Approach 2: If you want to Add/Concat DataRow to the array, then Do the following:

  1. initialize the arr_dataRow using Default New System.Data.DataRow() {}
  2. use the below code in assign:
arr_dataRow = arr_dataRow.Concat(New DataRow() { currentKeyValuePairOfTextAndDataRow.Value }).ToArray()

kv comes from keyvalue of dict.

Hi, I noted you misunderstood browse for types of dict.
Browse for types of dict is Dictionary<String, datarow□> NOT Dictionary<String, datarow>.

Oh. In that case you can directly assign

arr_datarow = currentKeyValuePairOfTextAndDataRow.Value

Obviously, rename the item to something smaller.

Before receiving your second suggestion, I managed to find the same answer by myself.
Thank you for your support anyway.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.