Attribute
程序员文章站
2022-07-14 13:02:30
...
Conditional 为条件控制,一般符合宏指令的才执行
Obsolete 通常用与提示方法过时,废弃的说明
#define DEBUG//定义一个宏指令
using System;
using System.Diagnostics;//Attribute 需要引入的文件
namespace AttributeTest
{
class Program
{
static void Main(string[] args)
{
Message.Print("Hello,World Print()");
Message.PrintDebug("Hello,World PrintDebug()");
Message.PrintLine("Hello,World PrintLine()");
}
}
public class Message
{
#region Code区域1
public static void Print(string msg)
{
Console.WriteLine(msg);
}
[Obsolete("This Function was not in used,Please use Print()",true)]
public static void PrintLine(string msg)
{
Console.WriteLine(msg);
}
[Conditional("DEBUG")]//DEBUG模式下可以使用此function
public static void PrintDebug(string msg)
{
Console.WriteLine(msg);
}
#endregion
}
}
推荐阅读
-
NET 特性(Attribute)
-
jQuery中[attribute^=value]选择器用法实例_jquery
-
关于laravel的获取器:get{xxxx}Attribute问题
-
Binary XML file line #19: <item> tag requires a ‘drawable‘ attribute or child tag defining a drawabl
-
c#自定义Attribute获取接口实现示例代码
-
Spring 2.0 RC4 Released: Heads-up on DTD/Schema Renaming, Scope Attribute
-
jQuery中[attribute=value]选择器用法实例_jquery
-
python错误:AttributeError: 'module' object has no attribute 's
-
C#属性(Attribute)用法实例解析
-
通过特性(attribute)为枚举添加更多信息示例