Foreach loop output as array instead of string.join


#1

Hi all,

I have these items that I get from the for each loop. I am hoping to assign these items into an array instead of string which I use string.join. could you please provide the syntax? Thanks in advance!
@ovi, if you may know?

Warm regards,
Lavina


#2

Hello @lavint,

Please refer to this link, if this is what you require! :slight_smile:


#3

Hi @Rishabh_Lakhera,

Thanks for your response! I’d like it to be String[ ] not String.

For each item in items
I do something
then Assign String[] itemString = … .ToArray()

Do you know the Syntax? Thanks!

Warm regards,
Lavina


#4

May i know what you’re looping through with for each? is it a list? or another array?


#5

Sure.

For each item in Directory.getfile blah
For each str in string[] strA
if item.Contains(str)
Assign string[] thisIsWhatINeed = … . ToArray()

String.join(blahblah).split.toArray()?

I am just wondering if there is a more efficient way in stead of join then split for the array.

Thanks


#6

@lavint

Could you please check if this helps you?
This is how i assigned the list items to the array.
Main (1).xaml (18.6 KB)


#7

Definitely! thanks @Rishabh_Lakhera
I think join then split maybe a more simple fit for my situation. Thank you very much though :slight_smile: