How do I convert an array list to hash separated string?


I am new to c# and I am using String.Join to attempt to turn an array list into a string that is hash separated, such as "1#2#3#4". I can't seem to get the syntax working correctly.

Here's what I'm trying:

ArrayList aryTest = new ArrayList();
string strTest = "";
strTest = string.Join("#", aryTest.ToArray(typeof(string)));

How about:

var list = new List<string>() { "1", "2", "3" };
var joined = string.Join("#", list);

An ArrayList is an "old" generation class, that does not implement the IEnumerable<T> interface that is needed for string.Join, and also is not an string[] or object[] array, which could be used in a call to string.Join.

You are better of using a List<string>, because then you will not have to do ToArray, to allocate a new array, just to create a string.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at


Login to comment


How to convert array into comma separated string in javascript

How do I convert a C# List<string[]> to a Javascript array?

How to convert a comma separated string to an array?

How to convert comma-separated String to List?

How do I convert a string to a list of chars?

How do I convert a Swift Array to a String?

How can I convert comma separated string into a List<int>

How can I convert a comma-separated string to an array?

How do I convert a CMake semicolon-separated list to newline-separated?

How to convert List<string> into String of Comma Separated Quotes from List

How do i convert a character array to a string?

How do I convert a TreeMap that is a <String, <List<String>> to String[][]?

How can I convert an array into a comma separated string?

How to convert object array to comma separated string?

How do i convert a String to a List<Map<String,String>>

How can I pass a list, array or string to be separated as a parameter to redshift

How to convert a comma separated string to an array in postgresql

Ruby/Rails: How do I convert a keys-values string(with array value included) to valid hash

How to convert the comma separated string or /n separated string into list in jquery?

How do I convert a string into a string array String()?

How do I convert a string to an array?

How do I extract a list of numbers separated by a space from a text file and convert them to an integer array. - Python

How do I convert an array or a list into a hashref?

How I convert string response into Array List

How do I turn a comma separated string field into an Array in MongoDB?

how can i convert my array data into comma separated string

How can i convert comma separated query String to a Array of Strings

How do I check whether comma separated elements of a string are in the list or not?

How do I convert a string of comma separated integers to just comma separated ints for a ExecuteSql command?

TOP Ranking

  1. 1

    How to return a single asset OhMyBrew Laravel Shopify

  2. 2

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    Loopback Error: connect ECONNREFUSED (MAMP)

  5. 5 port in URL

  6. 6

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  7. 7

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  8. 8

    Make a B+ Tree concurrent thread safe

  9. 9

    Group boxplot data while keeping their individual X axis labels in ggplot2 in R

  10. 10

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  11. 11

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  12. 12

    BigQuery - concatenate ignoring NULL

  13. 13

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  14. 14

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  15. 15

    Razor Page - How to redirect to another folder's page using asp-for tag helper

  16. 16

    "django.db.utils.ProgrammingError: relation "auth_user" does not exist" Django V2.0

  17. 17

    How to exclude a specific git submodule from update?

  18. 18

    how to fix CMake Error in CMakeLists.txt: Generator NMake Makefiles does not support platform specification, but platform x64 was specified

  19. 19

    Is there a way to ask the user before loading the website

  20. 20

    How to remove the extra space from right in a webview?

  21. 21

    Optimising manipulation of large vectors