(it does not work)Code:MyString = join({String1 , String2 , String3 , String4, String5},"")
_
Printable View
(it does not work)Code:MyString = join({String1 , String2 , String3 , String4, String5},"")
_
Why whould you think that it works ???
it needs to be:Quote:
Originally Posted by GremlinSA
and I give the arrayCode:MyString = join(ArrayVariable,"")
This works:Code:{String1 , String2 , String3 , String4, String5}
I have lines like:Code:ArrayVariable = {String1 , String2 , String3 , String4, String5}
MyString = join(ArrayVariable ,"")
When two of the strings String# are long, that code is very slow. I have lines with a short number of long strings, and a large number of short strings. The time is proportional to the number of small strings, because for each short string, all the long lines are copied again.Code:MyString = String1 & String2 & String3 & String4 & String5
String.Join() works much more faster, but I don't like dividing the code in many lines.
_
Marraco, have you seen this FAQ:
http://www.codeguru.com/forum/showthread.php?t=454776
or the StringArrayConverter thread:
http://www.codeguru.com/forum/showthread.php?t=454948
It may help
Yes, I had read it. (Thanks anyway for caring :) ). I fact I used String.Concat(data, data, data). Still I would like to know if there are a way, to use a string constant defined in place, in the way I have post.Quote:
Originally Posted by HanneSThEGreaT
For example, is valid to write:
but is invalid this line:Code:Dim MyArray as String() = {data, data, data}
maybe there is a way to do it that way, like:Code:String.Join("", {data, data, data} )
Just for curiosity.Code:String.Join("", New String()={data, data, data} )
'(it does not work)
_
Remove the =Quote:
Originally Posted by Marraco
Perfect. That is. :thumb:Quote:
Originally Posted by Alsvha
PD:I wonder why Microsoft had made it different that in the Dim line.
_
With the declaration, if you are going to declare an array like that, you need to give it values, so that the array can be initialised.Quote:
Originally Posted by Marraco
With the Join statement, the Join function expects an array of values, that is why using an already existing array works in there, else, like with your code, you created an array of values on the fly ( inside the Join method ) - you are not assinging those values to a variable or array ( as you did with the declaration ), your just supplying values to the Join method to work properly.
Does that make sense ¿
PS, I only now see what you wanted to achieve, sorry :p
I was whining why "=" is not required in:Quote:
Originally Posted by HanneSThEGreaT
When is required (as is reasonable) in:Code:Join(New String() {data,data,data},"") 'Is not Join(New String() = {data,data,data},"")
Code:Dim MyArray As String() = {data,data,data}
Don't sorry. You give help. Thanks. :thumb:Quote:
Originally Posted by HanneSThEGreaT