How to operate multiple contional features in C-sharp

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();
        }
    }
}
Sep.23,2021
  • Questions about the singleton pattern in unity?

    based on unity and C-sharp, there is a code from conception to implementation as follows. I don t understand why this code is singleton mode. public class BoidSpawner : MonoBehaviour{ static public BoidSpawner S; ..... public GameObjec...

    Jul.22,2021
Menu