#define DoTrace//这里定义了标注符号,注释掉该行,那么标注有 [Conditional("DoTrace")]特性的方法将不执行
using System;
using System.Diagnostics;
namespace ExofConditional
{
class Program
{
[Conditional("DoTrace")]
static void TraceMessage(string str)
{
Console.WriteLine(str);
}
static void Main(string[] args)
{
TraceMessage("Start of Main");
Console.WriteLine("doing Main ...");
TraceMessage("End of Main");
Console.ReadKey();
}
}
}
时间: 2024-11-03 03:27:46