Template:Csharp strings

esse quam videri
Revision as of 14:50, 23 September 2010 by Jeff (talk | contribs) (Created page with '==Strings== Strings are an object in c# *[http://msdn.microsoft.com/en-us/library/ms228364.aspx Strings (C# Programming Guide)] ** [http://msdn.microsoft.com/en-us/library/ms22…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Strings are an object in c#

String concatenation

+ is also used to concatenate strings

If you have two string that you want to combine into one string you can concatenate them. Or use the super jedi .net method String.Format method

<csharp>//Create a string and set it's value to "cool." string coolString = "cool"; //Do some concatenations and make it super cool Console.WriteLine ("Super " + "string " + "theory!!!\n" + "Is really " + coolString + ".");

string notherCoolString = "another " + coolString + " string."; Console.WriteLine(notherCoolString);

Console.WriteLine(String.Format("In Line formating of '{0}'", notherCoolString));


will output (remember \n is a new line)

    Super string theory!!!!
    Is really cool.
    another cool string.
    In Line formating of 'another cool string.'

Escape Sequences

The backslash character is used as a string escape sequence. It will escape the next character and change it's meaning. For example \" with output a ", \n with out put a newline and \\ with output a single \.