Basic of string in C#

String variable is used to store string data type.
+ is use to concatenate the two strings.
Data to the variable can be assigned on new line but can not break strings on next line to do that use + operator.

String variable can hold the new line or special characters by preceding it with the scape(\) character.
\n – new line
\t horizontal tab
\v vertical tab
\b backspace
\f form feed
\’ single quote
\a alert sound
\” double quote
\r carriage return
\\ backslash
null character
\uFFFF unicode character (4 digit hex number).

There are various methods to change the string but result of which is completely new string.
This is because string class is immutable.Its contain can not be changed unless the whole string is replaced.
Because of the performance cost of replacing the string we should use the string builder class, whenever we need to modify
string multiple times.
String builder is mutable objects and has several methods.

 

Advertisements

#string