Error BC30311: Value of type 'String' cannot be converted to 'String()'

Hi, I have a variable x of type String. How do I concatenate a new inner array to x? I tried using the assign activity where I assign x = x.Concat({“string1”, “string2”}).ToArray but I am facing the above issue that type String cannot be converted to String(). How do I solve this error, or is there another method to concatenate a new array of strings to my variable x?

example:
x = [[“a”, “b”], [“c”, “d”]]
x += [“e”, “f”]
printing x returns [[“a”, “b”], [“c”, “d”], [“e”, “f”]]

x is of type array of array of strings, not sure why it displays as a weird character in my original question

Hi @ttk

Try this
x = x.Concat({{"e", "f"}}).ToArray()

Hope it helps

use the surrounding ( ) when defining the inner array
grafik

And also
grafik

1 Like

@ttk
just check the feedback and lets get closed the topic by:
Forum FAQ - How to mark a post as a solution - News / Tutorials - UiPath Community Forum

both the .Append and .Concat method are able to compile, but when I debug the file, it gives me the error that I cannot assign 'x.Append({“e”, “f”}).ToArray to x.

however, if I swap out x and use {({“a”, “b”}), ({“c”, “d”})}.Append({“e”, “f”}).ToArray, I am able to compile and debug the file without any errors. this means that there is something wrong with x? but the variable x has a variable type String[][] or array of array of strings. what could be the issue then?

may I also know how you open that ‘Immediate’ console? the documentation says that the Immediate panel is only visible during debugging but I don’t see it.

and after I assigned “{({“a”, “b”}), ({“c”, “d”})}.Append({“e”, “f”}).ToArray” to y, I tried to print the inner array by doing the following:

  • using the For Each activity, for each currentItem in y
    use Message Box activity to print String.Join(“,”, currentItem)

but this just prints out “System.String[ ]”. how can I print for example “{“a”, “b”}” or “a, b” for each iteration of the inner array?

hi, I tried this and I get the compile error that value of type String (,) cannot be converted to String() because the array types have different number of dimensions

from above we had shown the working essentials and also datatypes can be derived, as it is marked within the immediate panel output

We recommend the following:

  • clear the exact needs
  • check the configured datatypes
  • correct / adapt if it is needed

If further assistance is needed:

  • Elaborate on - the exact needs
  • share with us in detail what was done in detail

Yes
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

we would avoid:

and can use the immediate / watch panel as well

thank you for sharing the link on debugging panels.

I realised that my x variable was null at initially hence I was unable to append to it. Instead of a String[ ][ ], I think it would be better to use a List<List<String_>_>, as in a List of List of String. However, under the variables panel, I tried to set the default value to New List(Of (New List(Of String))), but got a few errors stating that New is not valid in this context, and the value of type ‘List(Of(?,?))’ cannot be converted to List(Of List(Of String)). If that’s the case, how do i instantiate an empty list of list of string?

we assume that the project is set for using VB.Net

we have at least these options
grafik

Variable:
grafik

Init (or do it within an Assign Acitvity):
grafik

Adding elements samples
grafik

Init with more elements
grafik

And can shortcut to
grafik

For formal reasons we also mentione the activities:

And others

thanks for all your help!

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