我如何能有条件地编译我的C#的单声道和微软.NET? [英] How can I conditionally compile my C# for Mono vs. Microsoft .NET?

查看:107
本文介绍了我如何能有条件地编译我的C#的单声道和微软.NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道,如果我编译为单声道或MS .NET运行时条件编译开关。我怎样才能做到这一点?

I need a conditional compilation switch that knows if I am compiling for the mono or MS .NET runtime. How can I do this?

推荐答案

Mono的编译器定义 __ MonoCS __

The Mono compiler defines __MonoCS__

但是,但是,但是,单声道的整点是,你可以把你建立与VS的组装和单声道运行,反之亦然。

BUT, BUT, BUT, the whole point of Mono is that you can take an assembly that you built with VS and run it on Mono, or vice versa.

在我看来,如果你需要有单VS MS.NET的差异,那么你就需要在运行时要做出这些决定。

It seems to me that if you need to have Mono vs MS.NET differences, then you need to be making those decisions at run-time.

标准的方法来检测单在运行时:

The standard way to detect Mono at Runtime is:

bool runningOnMono = Type.GetType ("Mono.Runtime") != null;

这篇关于我如何能有条件地编译我的C#的单声道和微软.NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆