The string type is a sealed class type that inherits directly from object.
Instances of the string class represent an IMMUTABLE, fixed-length string of Unicode characters.
A String is called immutable because its value cannot be modified once it has been created
The string keyword is simply an alias for the predefined System.String class.
Values of the string type can be written as string literals:
C# supports two forms of string literals: regular string literals and verbatim string literals.
A regular string literal consists of zero or more characters enclosed in double quotes, as in "hello", and may include both simple escape sequences (such as \t for the tab character), hexadecimal escape sequences, and Unicode escape sequences.
A verbatim string literal consists of an @ character followed by a double-quote character, zero or more characters, and a closing double-quote character.
string c = "hello \t world"; // hello world
string d = @"hello \t world"; // hello \t world
object ob1 = "hello";
object ob2 = "hello";
string so1 = "hello";
string so2 ="hello";
so2.Replace('l','x'); // so2 unchanged
so2 = so1.Replace('l','x'); // so2 is "hexxo";
public void FixSection( ref string section)
{
section = "blabla";
}
string mySection = "";
FixSection(ref mySection); // mySection will be "blabla".
object [] sKey = new object[4];
sKey[0] = "hello1";
skey[1]= "hello2";
....
If you want to modify the value of a string use StringBuilder object.
-obislavu-