[Mono-devel-list] Environment.OSVersion.Platform for Unix
Miguel de Icaza
miguel at ximian.com
Mon May 9 15:32:51 EDT 2005
Hello,
> 2. Lots of existing code don't care about the framework version. In that
> case it's easier to use code that will work on both versions, like:
>
> using System;
>
> class Program {
>
> static void Main ()
> {
> int p = (int) Environment.OSVersion.Platform;
> if ((p == 4) || (p == 128)) {
> Console.WriteLine ("Running on Unix");
> } else {
> Console.WriteLine ("NOT running on Unix");
> }
> }
> }
>
> % mcs test2.cs
> % mono test2.exe
> Running on Unix
>
> % gmcs test2.cs
> % mono test2.exe
> Running on Unix
This approach is strongly recommended, and its the one that we should be
using inside our class libraries to avoid people mimicing the use of the
NET_2_0 define which will not be there for them.
Miguel
More information about the Mono-devel-list
mailing list