Is my code compiled on Mono (or Microsoft .NET)?

If you want to distinguish between your .NET program compiled on Mono and your program compiled on Microsoft Windows you can use the “__MonoCS_” pre-processor flag!

using System;
using System.IO;

public class AmIMono
{

    public static void Main()
    {
#if __MonoCS__
        Console.WriteLine("Hello Mono! :) ");        
#else
        Console.WriteLine("No Mono! :( ");
#endif
    }

}
 

mcs test.cs
./test.exe

via btk

Recent Entries

Leave a Reply

Enter this code