[Mono-list] Re: [Mono-devel-list] Environment.OSVersion.Platform for Unix

Miguel de Icaza miguel@ximian.com
Mon, 09 May 2005 15:32:51 -0400


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