Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiler #if directive to split between Mono and .NET [duplicate]

Tags:

c#

.net

mono

I need to dual-compile a class library for Mono on the Mac and .NET on the PC. There are some minor changes I want to make, but I was hoping to split the code using a compiler directive. Any suggestions?

like image 522
whitehawk Avatar asked Dec 10 '10 06:12

whitehawk


1 Answers

While a runtime check is probably preferable, with the Mono compiler, the pre-defined __MonoCS__ constant is useful, e.g.:

#if __MonoCS__
// Code for Mono C# compiler.
#else
// Code for Microsoft C# compiler.
#endif
like image 184
Stewart Avatar answered Sep 27 '22 17:09

Stewart