1. 使用 C# 关键字作为命名
public void OutputString(string @params)
{
Console.WriteLine(@parmas);
}
OutputString("好家伙, 电饭煲自己打开了.");
2. 原义解释字符串
pubilc void Example()
{
var filename1 = @"c:\users\tiehanhan\u6de6.txt";
var filename2 = "c:\\users\\tiehanhan\\u6de6.txt";
Console.WriteLine(filename1);
Console.WriteLine(filename2);
var @string = "歪比巴卜 \"我觉得很\u6de6\"!";
var string1 = @"歪比巴卜 ""我觉得很\u6de6""!";
Console.WriteLine(@string);
Console.WriteLine(string1);
}
3. 在编译器命名冲突的情况下区分使用哪个属性
using System;
public class Info : Attribute
{
private string information;
public Info(string info)
=> information = info;
}
public class InfoAttribute : Attribute
{
private string information;
public InfoAttribute(string info)
=> information = info;
}
public class Example
{
[@Info("哈喽哇, Main")]
public static void Main(string[] args)
{
}
[InfoAttribute("哈喽哇, Output")]
public static void Output(string value)
{
}
}