C# Program to Concatenate Two Strings

«
»

This is a C# Program to concatenate two strings.

Problem Description

This C# Program Concatenates Two Strings.

Problem Solution

Here the two strings are joined together to form a single string with a build in string function.

Program/Source Code

Here is source code of the C# Program to Concatenate Two Strings. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

/*
 * C# Program to Concatenate Two Strings
 */
using System;
class Program
{
    static void Main()
    {
        string s1 = "Good";
        string s2 ="Morning";
        string s3=string.Concat(s1, s2);
        Console.WriteLine(s3);
        Console.ReadLine();
    }
}
Program Explanation

This C# program is used to concatenate two strings. We have already defined two strings using ‘s1’ and ‘s2’ variables. Using ‘s3’ variable concatenate the two strings using Concat() function.

Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement
advertisement
Runtime Test Cases
 
GoodMorning

Sanfoundry Global Education & Learning Series – 1000 C# Programs.

If you wish to look at all C# Programming examples, go to 1000 C# Programs.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses.