Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

C# Concatenation [Beginner Level Tutorial]

C# Concatenation


What Is Concatenation?
In layman's terms, Concatenation is joining two or more things together.

How To Do It In C#?

For Starters, if you have not read my variables tutorial, or you do not know how to setup a variable, please view my thread here.
https://hackforums.net/showthread.php?tid=755046

Lets Get Started!

Begin by creating a new TextBox and a Button, also set up 2 new string variables.
Code
string conc1 = "Hello";
string conc2 = "HackForums";


Underneath this put the following:
Code
textBox1.Text = conc1 + " " + conc2;

textBox1.Text
This is literally the text that is present inside of your textBox.

conc1 + " " + conc2;
conc2 and conc2 are obviously your 2 variables holding your text.

" "
The reason for putting this is because you want a space in between your two words, without it the result would be "HelloHackforums".

+ + +
The reason for using a + operator is simply to join the variables together.

Spoiler (Click to View)

Conclusion:
Concatenation can be used with strings to join things together. It may be hard to think of a way to use it now, but believe me, opportunities present themselves.

Code:
Code
private void button1_Click(object sender, EventArgs e)
        {
            string conc1 = "Hello";
            string conc2 = "HackForums";

            textBox1.Text = conc1 + " " + conc2;
        }
http://www.pulsecodes.info
Computer and Information Science major.
Information Technology Apprentice.
Freelance Programmer.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Java] by SouthSide1990Jun 12, 2018 07:47 AM 2 318 Jun 12, 2018 07:47 AM
Last Post: Vanagander
[Java] by crosseraJan 11, 2017 10:03 AM 4 166 Jan 11, 2017 10:03 AM
Last Post: Hitmaster
[Python] by SuperHydraFeb 17, 2015 11:30 PM 9 271 Feb 17, 2015 11:30 PM
Last Post: clark.dll