string in C#

In many other programmin languages, a string is an array of charactes, but in C# Strings are object thus string is reference type.The string type represents a string of Unicode characters. string is an alias for System.String in the .NET Framework.
A C# string is an array of characters declared using the string keyword. A string literal is declared using quotation marks, as shown in the following example:

string str = “Welcome guest”;

Constructing Strings:
The easiest way to make a string is to use a string literal. in following example str is a string reference variable that is assigned a reference to a string literal:

string str = “Welcome guest”;

we can also create a string from a char array, for example:

char[] ArrStr = { ‘W’, ‘e’, ‘l’, ‘c’, ‘m’, ‘e’ };
string str = new string(ArrStr);

on here value of str will be ‘Welcome’.

concatenates strings:
we use + operator for concatenating strings

string str = “Welcome” + “Guest”;

using [] operator with string:
[] operator can be used for readonly access to individual characters of a string:

string str = “test”;
char a = str[0]; // a = ‘t’;
char b = str[1]; // b = ‘e’;
char c = str[2]; // c = ‘s’;
char d = str[3]; // d = ‘t’;

Verbatim string:
Verbatim string literals start with @ and are also enclosed in double quotation marks.
The advantage of verbatim strings is that escape sequences are not processed, which makes it easy to write, for example:

@”c:\NewFolder\a.txt” // rather than “c:\\NewFolder\\a.txt”