Umer Ahmad
0
Q:

C# strings

//A Basic stiring is just a string that holds text and you can concatinate.
//You must escape these strings. More on escape can be found below
string BasicString = "This is a boring old string"
  
//Interpolation Strings are strings that are interpertated at run time for your local vars
//This string must still use escape chars such as \\ and '{' char must be typed twice to show up.
int Num = 1;
String InterpolationString = $"The numer is {Num}. this way {{ can mark values"
//the intel on this web app has not incorperated this sense yet

//Verbatim Strings are used to typeout stings that will not need to be exscaped
//beginings are marked with a @
// Ther char '"' can be inserted by repeating it twice since there is no ecscaping
string VerbatimString = @"This string does not need to be escaped making it easer to say ""C:\\"""

//All strings can be concatinated with the + operater.
string ConcatedString = "This " + "will be "
//If you already have a var to concatinate you can short hand this.
string ConcatedString += "fun!" //The string should now be "This should be fun!"

//Escaping chars are used to specify special chars since not all are on the keyboard or have a graphical representation
//It is represented as the char '\' followed by a another char for the char
//Here are a few:
// EChar	What it repesents
// \' 		Single quote
// \" 		Double quote
// \\ 		Backslash
// \0 		Null
// \a 		Alert
// \b 		Backspace
// \f 		Form feed
// \n 		New line
// \r 		Carriage return
// \t 		Horizontal tab
// \v 		Vertical tab
// \u 		Unicode escape sequence (UTF-16)
// \U 		Unicode escape sequence (UTF-32)
// \x 		Unicode escape sequence similar to "\u" except with variable length
  
//Unicodes are for special chars that do not have a quick escap char or if you just want to type it out
// for example \u0000 is null.
7
using namespace std;
0
private string text;

Console.WriteLine(text);
-1

New to Communities?

Join the community