Skip to content

Instantly share code, notes, and snippets.

@sandcastle
Last active August 29, 2015 14:00
Show Gist options
  • Save sandcastle/096f89b013587fa53b28 to your computer and use it in GitHub Desktop.
Save sandcastle/096f89b013587fa53b28 to your computer and use it in GitHub Desktop.
Platform check for Mono and Windows
/// <summary>
/// Helper methods for determining the platform.
/// </summary>
public static class Platform
{
/// <summary>
/// Gets if the platform is Windows NT or later.
/// </summary>
public static bool IsWindows
{
get
{
return (Environment.OSVersion.Platform == PlatformID.Win32NT);
}
}
/// <summary>
/// Gets if the platform is Mono on Unix or Mac.
/// </summary>
public static bool IsMono
{
get
{
var platform = (int)Environment.OSVersion.Platform;
return (platform == 4 /* Unix */ || platform == 6 /* MacOSX */ || platform == 128 /* Legacy */);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment