ARRAY LIST TO STRING
-
how to convert array list into single string seperated with spaces
the quieter u become more u hear
-
how to convert array list into single string seperated with spaces
the quieter u become more u hear
You'd wanna look at the String.Concat[^] method.
:bob: Kristian Sixhoej "You can always become better." - Tiger Woods
-
how to convert array list into single string seperated with spaces
the quieter u become more u hear
-
how to convert array list into single string seperated with spaces
the quieter u become more u hear
-
string result = ""; foreach(object item in ArrayList) { result += item.ToString() + " "; } result = result.TrimEnd(new string[]{" "});
that should do itIf only MySelf.Visible was more than just a getter...
You can better use the StringBuilder for these kind of operations, they are faster:
StringBuilder result = new StringBuilder();
foreach(object item in ArrayList)
{
result.AppendLine(item.ToString());
}
String result2 = result.ToString();Now you have them seperated by a linebreak. You can also just use the append like this to separate by spaces:
StringBuilder result = new StringBuilder();
foreach(object item in ArrayList)
{
result.Append(item.ToString() + " ");
}
String result2 = result.ToString();
result2 = result2.Remove(result2.Length-1); -
You can better use the StringBuilder for these kind of operations, they are faster:
StringBuilder result = new StringBuilder();
foreach(object item in ArrayList)
{
result.AppendLine(item.ToString());
}
String result2 = result.ToString();Now you have them seperated by a linebreak. You can also just use the append like this to separate by spaces:
StringBuilder result = new StringBuilder();
foreach(object item in ArrayList)
{
result.Append(item.ToString() + " ");
}
String result2 = result.ToString();
result2 = result2.Remove(result2.Length-1);Deresen wrote:
result.Append(item.ToString() + " ");
when result is a StringBuilder you should not use string concatenation at all! Instead do:
result.Append(item.ToString());
result.Append(" ");:)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 11:43 PM
-
You can better use the StringBuilder for these kind of operations, they are faster:
StringBuilder result = new StringBuilder();
foreach(object item in ArrayList)
{
result.AppendLine(item.ToString());
}
String result2 = result.ToString();Now you have them seperated by a linebreak. You can also just use the append like this to separate by spaces:
StringBuilder result = new StringBuilder();
foreach(object item in ArrayList)
{
result.Append(item.ToString() + " ");
}
String result2 = result.ToString();
result2 = result2.Remove(result2.Length-1);thanks a lot its working fine
the quieter u become more u hear