Home c# rowing in C #

rowing in C #

Author

Date

Category

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:

  1. Addition of rows using the symbol
  2. StringBuilder
  3. string.join
  4. string.concat
  5. 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];
}
Previous articleDepth and Height Supported
Next articleConsole Log

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions