How to get one line from the row array?
was:
string [] Many = {"AB", "BC", "CD", "DE"};
became:
string one = "abbccdde";
Answer 1, Authority 100%
string.join hits the elements of the specified array or collection elements by placing between them a given separator.
string one = string.join (NULL, MANY);
Answer 2, Authority 62%
To do this, there is a special String.concat
string [] Many = {"AB", "BC", "CD", "DE"};
String One = String.concat (MANY);
Some Concat
methods are used within themselves StringBuilder , for example, the method accepting ienumerable & lt; T & GT; Values
. Other overloads are used within themselves unsafe code , for example, the method accepting Params String [] Values
. All this should give good performance when row concatenation.
Answer 3, Authority 31%
You can still use StringBuilder.APPend , for example:
string [] Many = {"AB", "BC", "CD", "DE"};
STRINGBUILDER SB = new stringbuilder ();
Many.Foreach (X = & GT; SB.APPEND (X));
Console.WriteLine (String.Format ("Result:" + SB)); // Result: abbccdde
Available Merging Methods Rows:
- Addition of rows using the
symbol
- StringBuilder
- string.join
- string.concat
- String.Format
Answer can be supplemented with additional ways, if any.
Answer 4, Authority 12%
the most banal probably the way:
string [] Many = {"AB", "BC", "CD", "DE"};
String One = "";
For (int i = 0; I & lt; Many.Length; I ++)
{
One + = Many [i];
}