Hi All, I’m pretty new in all of these. Pls forgive me if my question structure is a little weird.
Per shown in the image:
I’m storing several values in an Array String Type called ErrorArray
Objective is to separate the values into AxArray BxArray and CxArray.
2.1 Whereby each of the variables above are Array String type
My questions:
Why is it that if in the ‘Default’ field in AxArray, why do I need to use ‘new string(){}’?
1.1 I’m aware that if I don’t do the above, it’ll return Error: "Assign: Value cannot be null. (Parameter ‘first’). I just don’t get the rationale/logic of the error and why using new string(){} would help resolve the error
Explanation as to the format ‘new string (){}’. Why is there a need for () and {} and in such format?
How does ‘AxArray.Concat({Value}).ToArray’ work together with the default value ‘new string(){}’
3.1 By logic, the result of Value is for example “Ax001”, hence shouldn’t concating brings about: “AxAx001”?
Why is it when displaying a result of an array, the String.Join(" ", AxArray) function is used here? I’m aware that if I use AxArray.ToString the resut then becomes ‘System.String’. Why does the system displays this?
Note: for context, I found the solution in the UiPath academy. Please feel free to redirect me if I’m not asking the right questions above. Much appreciated!
When Checked there was a Similar discussion done previously, check if the below post could answer your Queries :
For a more general Answer to all of the asked Questions :
We are using .Net Framework/.Net Core or .Net Syntax in the Expressions that we use within the UiPath Environment and hence we would need to adhere to the Vb.net / C# syntax and methodical approaches.
It initializes the variable. If you were doing this all in vb code, you’d use a line like…
Dim myVar = New String(){}
Explanation as to the format ‘new string (){}’. Why is there a need for () and {} and in such format?
New String() means “new array of string” while the {} is an empty array you’re initializing it as.
In general, Arrays can be confusing because they must be declared with the expected number of elements. I recommend changing your variable datatype to:
And then initialize it as a list. Lists are more flexible.
Why is it when displaying a result of an array, the String.Join(" ", AxArray) function is used here? I’m aware that if I use AxArray.ToString the resut then becomes ‘System.String’. Why does the system displays this?
Because you can’t directly convert a complex datatype (like array) to string. The Join method concatenates all the values into a string.