简体   繁体   English

DNX Core 5.0库可针对任何平台。 没有System.Random类。 解决方法或选项?

[英]DNX Core 5.0 library to target any platform. No System.Random class. Workarounds or options?

I am trying out the Visual Studio 2015 RC project template for creating a class library 我正在尝试使用Visual Studio 2015 RC项目模板来创建类库

that can target any platform 可以针对任何平台

says Visual Studio. Visual Studio说。

A new project has 2 references: DNX 4.5.1 and DNX Core 5.0. 一个新项目有两个参考:DNX 4.5.1和DNX Core 5.0。 It appears that System.Random is not available in DNX Core 5.0. 似乎System.Random在DNX Core 5.0中不可用。 (The same is true for the .NET Core 5.0 Console project template.) (.NET Core 5.0控制台项目模板也是如此。)

For .NET Core libraries/apps, what options are there for generating random numbers? 对于.NET Core库/应用程序,可以使用哪些选项生成随机数?


To truly target any platform , I guess one could implement a pseudorandom number generator, or wait until a DNX Core-compatible reference is available, that has someone else implement a PRNG. 要真正定位到任何平台 ,我想一个人可以实现一个伪随机数生成器,或者等到DNX Core兼容的引用可用之后,再由其他人实现PRNG。 Microsoft could be that someone by the time 2015 is no longer "RC". 微软可能会在2015年使某个人不再“ RC”。

I think it's included in System.Runtime.Extensions package . 我认为它包含在System.Runtime.Extensions包中 Add it to dependencies and run dnu restore if you are building from the command line. 如果从命令行构建,则将其添加到依赖项并运行dnu restore Then it should build. 然后,它应该建立。

Look at Microsoft's System.Random source code 查看微软的System.Random源代码

See if a copy & paste will compile. 查看复制和粘贴是否可以编译。

If you don't intend to generate lots of instances of PRNGs, then DateTime.Now.Ticks is supported by DNX 5.0 and could be used as the seed. 如果您不打算生成许多PRNG实例,则DNX 5.0支持DateTime.Now.Ticks并将其用作种子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM