如何检测我的C#/ F#代码在单声道或.NET上运行的平台?

pro*_*eek 2 .net mono

我需要使用.NET或MONO进行C#/ F#编程.我怎么知道我的C#/ F#代码在哪个平台上运行?

Mat*_*hen 6

你不应该这样做.但是,如果确实有必要,可以检查Mono.Runtime类型.从单声道常见问题解答:

Type t = Type.GetType ("Mono.Runtime");
if (t != null)
    Console.WriteLine ("You are running with the Mono VM");
else
    Console.WriteLine ("You are running something else");
Run Code Online (Sandbox Code Playgroud)