C # use command in the pre-warning

C # use command in the pre-warning
grey_csdn

            Speaking in a pre-warning function in the C language also exist. Although the preparation of the code I have not used, but look at the code and the code generated code MATLABsimulink often see such usage. The use of C # might Similarly, all my late should learn to master a simple little technique and application.

            First write a Demo Code:

using System;

usingSystem.Collections.Generic;

usingSystem.Linq;

usingSystem.Text;

usingSystem.Threading.Tasks;


namespace warning{

    class Program{

        static void Main(string[] args){

#if XXX
            Console.WriteLine("OK!");
#else
#warning"XXX not defined!"
#endif
        }
    }
}

            As the code above, this function can be used to compile code for checking the configuration information. If the information is wrong, the corresponding warning message appears at compile time. Specifically similar to the following:

            Alternatively, you can give us tips a part of the success of the message at the right time. This is a good idea, functions are also worth trying.

Published 17 original articles · won praise 224 · views 290 000 +

Guess you like

Origin blog.csdn.net/cxu123321/article/details/103754421