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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s