to achieve the effect of logical and operations on symbols, you can define sequence conditional methods. For example, the second method can be executed only if both An and B are defined:
[Conditional ("A")]
static void DoIfA ()
{
DoIfAandB();
}
[Conditional ("B")]
static void DoIfAandB ()
{
// Code to execute when both A and B are defined...
}
after testing, only the definition of Bmai DoIfAandB can be executed. The following code outputs B.
-sharpdefine B
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
namespace
{
class Program
{
[Conditional("A")]
static void DoIfA()
{
DoIfAandB();
}
[Conditional("B")]
static void DoIfAandB()
{
Console.WriteLine( "B" );
// Code to execute when both A and B are defined...
}
static void Main(string[] args)
{
DoIfAandB();
}
}
}