Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET equivalent of java.util.Arrays.toString(...) methods in Java

In Java, the java.util.Arrays class have several static toString(...) methods that take an array and return its string representation (i.e. the string representation of the contents of the array separated by commas and the whole representation enclosed in square brackets -- e.g. "[1, 2, 3]").

Is there an equivalent method/functionality in .NET?

I am looking a for method that does this without resorting to manually constructing a loop/method to iterate through the array.

like image 566
maxyfc Avatar asked Feb 01 '26 00:02

maxyfc


1 Answers

The String.Join method.

[You will need to add the square brackets yourself]

like image 62
Mitch Wheat Avatar answered Feb 03 '26 12:02

Mitch Wheat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!