C# 2.0学习之--条件编译

csc CondMethod.cs tracetest.cs /d:DEBUG
tracetest A B C

//Copyright (C) Microsoft Corporation.  All rights reserved.

// TraceTest.cs
// compile with: /reference:CondMethod.dll
// arguments: A B C
using System;
using TraceFunctions;
using System.Diagnostics;

public class TraceClient
{
   public static void Main(string[] args)
   {
      Trace.Message("Main Starting");
  
      if (args.Length == 0)
      {
          Console.WriteLine("No arguments have been passed");
      }
      else
      {
          for( int i=0; i < args.Length; i++)   
          {
              Console.WriteLine("Arg[{0}] is [{1}]",i,args[i]);
          }
      }

       Trace.Message("Main Ending");
   }
}

   public class Trace
   {
       [Conditional("DEBUG")]
       public static void Message(string traceMessage)
       {
           Console.WriteLine("[TRACE] - " + traceMessage);
       }
   }

posted @ 2006-06-23 18:34  Gavin Liu  阅读(342)  评论(0编辑  收藏  举报

Right people get the right information at the right time.
以技术求生存,以市场求发展;学以至用,开拓创新;达技术之颠峰,至市场之广阔!