Using/Debug Option During Compilation


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)]

Up Next
    Ebook Download
    View all
    Learn
    View all