Created
December 22, 2009 16:18
-
-
Save SamWM/261827 to your computer and use it in GitHub Desktop.
ArrayList to String
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <summary> | |
| /// Converts an array list to a string. | |
| /// </summary> | |
| /// <param name="ar">Array list</param> | |
| /// <returns>Comma deliminated string</returns> | |
| public static string ArrayListToString(ArrayList ar) | |
| { | |
| return ArrayListToString(ar, ','); | |
| } | |
| /// <summary> | |
| /// Converts an array list to a string. | |
| /// </summary> | |
| /// <param name="ar">Array list</param> | |
| /// <param name="delim">Deliminator (char)</param> | |
| /// <returns>Deliminated string (using supplied 'char' deliminator)</returns> | |
| public static string ArrayListToString(ArrayList ar, char delim) | |
| { | |
| return ArrayListToString(ar, delim.ToString()); | |
| } | |
| /// <summary> | |
| /// Converts an array list to a string. | |
| /// </summary> | |
| /// <param name="ar">Array list</param> | |
| /// <param name="delim">Deliminator (string)</param> | |
| /// <returns>Deliminated string (using supplied 'string' deliminator)</returns> | |
| public static string ArrayListToString(ArrayList ar, string delim) | |
| { | |
| return string.Join(delim, (string[])ar.ToArray(typeof(string))); | |
| } | |
| /// <summary> | |
| /// Converts a string to an array list. | |
| /// </summary> | |
| /// <param name="str">String to convert</param> | |
| /// <param name="delim">Deliminator to split by</param> | |
| /// <returns>Array list</returns> | |
| public static ArrayList StringToArrayList(string str, char delim) | |
| { | |
| return new ArrayList(str.Split(delim)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment