Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hello OS with C# & mono?

Tags:

.net

mono

Is there a way to identify in which OS we are running mono, with C# code?

Some sort of Hello World, but instead of using a fixed string as an output use the current OS?

like image 306
Raúl Roa Avatar asked Feb 28 '23 21:02

Raúl Roa


1 Answers

Try System.Environment.OSVersion

You can also detect if your code is run under Mono or MS.NET:

if (Type.GetType("Mono.Runtime") != null) 
{
    // we're on Mono
    IsMono = true;
} 
else
    IsMono = false;
like image 66
Igor Brejc Avatar answered Mar 03 '23 11:03

Igor Brejc