Declare String in c#

// Declare without initializing. 
string message1;
// Initialize to null. 

string message2 = null// Initialize as an empty string. 

// Use the Empty constant instead of the literal "".

string message3 = System.String.Empty;
// Use System.String if you prefer.
System.String greeting = "Hello World!";
// Use a const string to prevent 'message4' from 

// being used to store another string value. 

const string message4 = "You can't get rid of me!";
// Use the String constructor only when creating 

// a string from a char*, char[], or sbyte*. 

// System.String documentation for details. 

char[] letters = { 'A', 'B', 'C' };
string alphabet = new string(letters);
Ebook Download
View all
Learn
View all