C# 语法练习(2): 字符转义


\'  \"  \\  \0  \a  \b  \f  \n  \r  \t  \U  \u  \v  \x


本例效果图:

C# 语法练习(2): 字符转义

代码:

using System;



class MyClass

{

    static void Main()

    {

        Console.WriteLine("\"");

        Console.WriteLine("\u0022");

        Console.WriteLine(@"\u0022");



        Console.WriteLine();



        Console.WriteLine("\'");

        Console.WriteLine("'");

        Console.WriteLine("\u0027");



        Console.WriteLine();

 

        Console.WriteLine("\\");

        Console.WriteLine("\u005C");

        Console.WriteLine(@"\\");



        Console.WriteLine();



        Console.WriteLine("C:\\Windows\\Temp");

        Console.WriteLine(@"C:\Windows\Temp");

        Console.WriteLine(@"C:\\Windows\\Temp");



        Console.WriteLine();



        Console.WriteLine("\u4E07\u4E00");

        Console.WriteLine("\x4E07\x4E00");

        Console.WriteLine("\U00004E07\U00004E00");



        Console.WriteLine();



        Console.WriteLine("\u0041\u0042\u0043");

        Console.WriteLine("\x0041\x0042\x0043");

        Console.WriteLine("\x41\x42\x43");



        Console.ReadKey();

    }

}


 
   

你可能感兴趣的:(C#)