When to use .ToArray when printing a list?


I am confused with the .ToArray function in VB/Ui Path. Why sometimes when printing a list only requires String.Join("," sampleList) but sometimes requires String.Join("," sampleList.ToArray)?


Check this below link, @quan9784

Hope this may help you :slight_smile:


I have the exact same question, but I’m not getting my answer from the article you mentioned. I’m very new to programming, so I may be missing some basic understanding of it.

I was doing the Data Manipulation practice from the UIpath academy when I noticed that I had my log message written as String.join(", “,ListNew), while the answer shows it should be String.join(”, ",ListNew.ToArray). They both work though and give the same result, so why and when do we need to add .ToArray to the list variable?