漠漠星的专栏

  有水、有草、有星星,日月星辰,天下之大;以技术求生存,以市场求发展;学以至用,开拓创新;达技术之颠峰,至市场之广阔!...

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);
       }
   }

阅读更多
上一篇C# 2.0学习之--集合2
下一篇C# 2.0学习之--代理1
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭