C # and C + +, as well as preprocessing directives, let's look at preprocessing directives in C #.
#region
Code folding function, with #endregion use, as follows:
Click below:
Conditional preprocessing
Conditional preprocessing can determine the final compiled code based on the conditions given, in other words, you can exclude the specified code from compiling.
#define
Define a macro, and note that if you define a name, you do not need a value.
The macro definition is generally written in the first line.
#define IOS
This means that the macro for iOS is defined.
#undef
Cancel a macro definition, as follows:
#undef IOS
This will cancel the macro definition of iOS.
#if, #else, #elif, #endif
For specific instructions, show examples below:
1 #define ANDROID 2 #define iOS 3 #undef iOS 4 5 using System; 6 7 namespace Study 8 {9 class PROGRAM10 { One by one static void Main (string[] args) {#if ANDROID15 Console.WriteLine ("The Code of the Android platform is written here. "); #elif IOS17 Console.WriteLine (" IOS platform code is written here. "); #else19 Console.WriteLine (" The Code for the other platforms is written here. "); #endif21 console.read (); }24 }25}
In unity, the corresponding macros have been defined for the corresponding platforms and versions, and the following links can be viewed:
Http://docs.unity3d.com/Manual/PlatformDependentCompilation.html
#warning, #error
These two instructions allow the editor to make warnings and errors, with general and conditional directives for debugging.
1 #warning shouldn't write like this here! 2 #error It's wrong to write like this here!
#line
With #warning and #error, you can set the exact number of lines for an error or warning.
1//200 Line problem 2 #line 200 "optional file name, indicating the specific problem file, without the suffix name. "3//recovery rows are the current number of rows 4 #line default
#pragma
This instruction can be extended by ourselves to complete specific functions, here is not much to say, to everyone a link to the article:
http://blog.csdn.net/jx_kingwei/article/details/367312
C # Learning notes: Preprocessing directives