Ok, this is a dumb thing that I'm sure I've done dozens of times but for some reason I can't find it.
I have an array... And want to get a string with the contents of that array separated by a delimited...
Where is the .Join() method that I can't find?
(This is .Net 2.0, I don't have any LINQ stuff)
Thank you!
Array.prototype.join() The join() method creates and returns a new string by concatenating all of the elements in an array (or an array-like object), separated by commas or a specified separator string. If the array has only one item, then that item will be returned without using the separator.
In C#, Join() is a string method. This method is used to concatenates the members of a collection or the elements of the specified array, using the specified separator between each member or element.
The "&" operator joins two strings together. Example: Dim String1 As String = "123" Dim String2 As String = "456" Dim String3 As String String3 = String1 & String2 ' Results in "123456". The "+" operator may be used in place of "&".
The arr. join() method is used to join the elements of an array into a string. The elements of the string will be separated by a specified separator and its default value is a comma(, ).
If you're working with strings, then String.Join
is probably what you're looking for.
It is on the string class
String.Join(",", new string[] {"a", "b", "c"});
Edit for ints to string
int[] integers = new int[] { 1,2,3,4,5 }; String.Join(",", Array.ConvertAll<int, String>(integers, Convert.ToString));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With