using System;
class MainClass
{
static void Main(string[] args)
{
char MyChar = "\0";
Console.WriteLine(MyChar);
}
}
Escape Sequence Character Name Unicode Encoding
\" Single quote 0x0027
\" Double quote 0x0022
\\ Backslash 0x005C
\0 Null 0x0000
\a Alert 0x0007
\b Backspace 0x0008
\f Form feed 0x000C
\n newline 0x000A
\r Carriage return 0x000D
\t Horizontal tab 0x0009
\v Vertical tab 0x000B
\uxxxx Unicode character in hex \u0029
using System;
using System.Collections.Generic;
using System.Text;
class Program
{
static void Main(string[] args)
{
string strWithTabs = "Model\tColor\tSpeed\tPet Name\a";
Console.WriteLine(strWithTabs);
Console.WriteLine("Everyone loves \"Hello World\"\a");
}
}
using System;
class Example {
public static void Main() {
Console.WriteLine("\"Why?\", he asked.");
}
}
using System;
class Example {
public static void Main() {
Console.WriteLine("Line One\nLine Two\nLine Three");
}
}
using System;
class Example {
public static void Main() {
Console.WriteLine("One\tTwo\tThree");
Console.WriteLine("Four\tFive\tSix");
}
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using System.Security.Cryptography;
public class MainClass
{
public static void Main()
{
Console.WriteLine("Single quote \\": {0} ({1})", "\"", (int)"\"");
Console.WriteLine("Double quote \\\": {0} ({1})", "\"", (int)"\"");
Console.WriteLine("Backslash \\\\: {0} ({1})", "\\", (int)"\\");
Console.WriteLine("Unicode null \\0: {0} ({1})", "\0", (int)"\0");
Console.WriteLine("Alert \\a: {0} ({1})", "\a", (int)"\a");
Console.WriteLine("Backspace \\b: {0} ({1})", "\b", (int)"\b");
Console.WriteLine("Horizontal tab \\t: {0} ({1})", "\t", (int)"\t");
Console.WriteLine("Newline \\r: {0} ({1})", "\r", (int)"\r");
Console.WriteLine("Vertical quote \\v: {0} ({1})", "\v", (int)"\v");
Console.WriteLine("Form feed \\f: {0} ({1})", "\f", (int)"\f");
Console.WriteLine("Carriage return \\r: {0} ({1})", "\r", (int)"\r");
}
}
using System;
using System.Collections.Generic;
using System.Text;
class Program
{
static void Main(string[] args)
{
Console.WriteLine(@"C:\MyApp\bin\Debug\a");
}
}
using System;
using System.Collections.Generic;
using System.Text;
class Program
{
static void Main(string[] args)
{
// White space is preserved with verbatim strings.
string myLongString = @"This is a very
very
very
long string";
Console.WriteLine(myLongString);
}
}