w3resource

C#: Concatenate the array values of strings

C# Sharp String: Exercise-37 with Solution

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.

C# Sharp Code Editor:

Improve this sample solution and post your code through Disqus

Previous: 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.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/csharp-exercises/string/csharp-string-exercise-37.php