Working with Strings

C# supports a reference type called string. The string data type represents a string of Unicode characters.

Note Unicode is a world-wide standard for character encoding. Unicode characters are 16 bits, which allows for 65,536 possible characters. The ANSII characters are 8 bits, and allow for 256 possible characters.

Use the following to create and initialize a string in C#:

string MyString;

As with all variables, you can initialize a string on the same line as its declaration:

string MyString = "Hello from C#!";

0 0

Post a comment