Concatenating Strings


The last section of my basic guide is how to concatenate strings, or in simple terms, adding two different words together side by side. So, if you wanted to write your full name in a complicated way, you’d use this method.


What you need to do for this, create a new console program by the name of "cStringEx". Type these lines of code. ‘String strFirstN = "(your first name)"; / String strLastN = "(your last name)";’. These are your standard declaring lines to declare your string values.



After that, you need to write this line, ‘Console.WriteLine(String.Concat(strFirstN, " ", strLastN));’. What this does is it’s telling the console to print the two strings but to concatenate them at the same time. So that they appear to be together as a whole. Add a ReadLine statement to the end as well.



Well, you learned many of the basics of C#, such as: Making a console and form program, creating output, lots of different variable concepts you can use in C#, how to get input, math operations, and lastly how to add or concatenate strings together. That wraps it up for this guide and I hope you learned a lot on how to use the programming language, c sharp. Good luck in your programming career!