ARTICLE

Using/Debug Option During Compilation

Posted by sayginteh Articles | C# Language July 15, 2001
This source code below is an an example of how to use /debug option during compilation.
Reader Level:

Beta 2 compliant

This source code below is an an example of how to use /debug option during compilation.

Best wishes and good luck ! 

Source Code

/*
File name : Debugging .cs
Author : Say Gin Teh
*/
using System;
using System.Diagnostics; // Need to add this when using "conditional"
public class Debugging
{
private int r = 0;
public Debugging (int r)
{
this.r = r;
}
public int R
{
get { return r; }
set { r = value;}
}
public static void Main()
{
methodA();
methodB();
methodC();
methodD();
methodE();
methodF();
}
public static void methodA()
{
Console.WriteLine("Method A");
}
[Conditional("saygin")]
// Basically - do this method only when compiled with /d:saygin
public static void methodB()
{
Console.WriteLine("Method B - has [conditional(saygin)]");
}
public static void methodC()
{
Console.WriteLine("Method C");
}
public static void methodD()
{
Console.WriteLine("Method D");
}
[Conditional("alex")]
public static void methodE()
{
Console.WriteLine("Method E - has [conditional(alex)]");
}
[Conditional("saygin"),Conditional("alex")]
public static void methodF()
{
Console.WriteLine("Method F - has [conditional(saygin),conditional(alex)]");
}
}

The output

1] Compiling : csc /d:saygin Debugging.cs
>Debugging.exe
Method A
Method B - has [conditional(saygin)]
Method C
Method D
Method F - has [conditional(saygin),conditional(alex)]

2] Compiling : csc Debugging.cs
>Debugging.exe
Method A
Method C
Method D

3] Compiling : csc /d:saygin;alex Debugging.cs
>Debugging.exe
Method A
Method B - has [conditional(saygin)]
Method C
Method D
Method E - has [conditional(alex)]
Method F - has [conditional(saygin),conditional(alex)]

4] Compiling : csc /d:alex Debugging.cs
>Debugging.exe
Method A
Method C
Method D
Method E - has [conditional(alex)]
Method F - has [conditional(saygin),conditional(alex)]

Login to add your contents and source code to this article
post comment
     
COMMENT USING
PREMIUM SPONSORS
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Join a Chapter