Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
What is the operator that concatenates two or more string objects in C#?
Use operator + to concatenate two or more string objects.
Set the first string object.
char[] c1 = { 'H', 'e', 'n', 'r', 'y' };
string str1 = new string(c1);
Now, set the second string object.
char[] c2 = { 'J', 'a', 'c', 'k' };
string str2 = new string(c2);
Now display the concatenated strings using + operator.
Example
using System.Text;
using System;
class Program {
static void Main() {
char[] c1 = { 'H', 'e', 'n', 'r', 'y' };
string str1 = new string(c1);
char[] c2 = { 'J', 'a', 'c', 'k' };
string str2 = new string(c2);
Console.WriteLine("Welcome " + str1 + " and " + str2 + "!");
}
}
Output
Welcome Henry and Jack!
Advertisements
