等效于核心clr的Environment.Version [英] Environment.Version equivalent in core clr
本文介绍了等效于核心clr的Environment.Version的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码对dnx451
框架有效,但对dnxcore50
The following code is valid for the dnx451
framework but not the dnxcore50
string ver = Environment.Version
此方法不存在:
dnxcore50框架中是否有等效的属性?
Is there an equivalent property in the dnxcore50 framework?
根据Victors的答案,您可以使用PlatformServices.Default.Runtime
,例如:
as per Victors answer you can use PlatformServices.Default.Runtime
eg:
Console.WriteLine("env: {0} {1}", PlatformServices.Default.Runtime.RuntimeType, PlatformServices.Default.Runtime.RuntimeVersion);
输出:(在dnx451上)
output: (on dnx451)
env:Clr 1.0.0-rc1-16231
env: Clr 1.0.0-rc1-16231
输出:(在dnxcore50上)
output: (on dnxcore50)
env:CoreClr 1.0.0-rc1-16231
env: CoreClr 1.0.0-rc1-16231
推荐答案
You can use the properties in IRuntimeEnvironment to get information about the runtime. The following properties are available:
- RuntimeType
- RuntimeArchitecture
- RuntimeVersion
- RuntimePath
这篇关于等效于核心clr的Environment.Version的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文