w3resource

C#: Concatenate the array values of strings


Write a C# Sharp program to concatenate string array values.

Sample Solution:-

C# Sharp Code:

using System;

public class Example37
{
    public static void Main()
    {
        // Make an array of strings. Note that we have included spaces.
        string[] str = { "hello ", "welcome ", "to ", "C# Sharp ",
                        "create ", "Windows ", "client ", "applications "};

        // Put all the strings together using string.Concat().
        Console.WriteLine(string.Concat(str));

        // Sort the strings in the array.
        Array.Sort(str);

        // Concatenate the sorted strings and display the result.
        Console.WriteLine(string.Concat(str));
    }
}

Sample Output:

hello welcome to C# Sharp create Windows client applications                                                  
                                                                                                              
hello applicationsC# Sharp client create to welcome Windows 

Flowchart :

Flowchart: C# Sharp Exercises - Concatenate the array values of strings.

Go to:


PREV : Write a C# Sharp program to concatenate three strings and display the result.
NEXT : Write a C# Sharp program to determine whether the string "birds" is a substring of a familiar.

C# Sharp Code Editor:



Improve this sample solution and post your code through Disqus

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.