在 C# 和 DateTime 中嵌入 IronRuby

发布于 2024-08-05 15:08:07 字数 276 浏览 1 评论 0原文

当我嵌入 IronRuby 时,获取对 Ruby 的 DateTime/Date 类或 .NET 的 System.DateTime 的引用的正确方法是什么。当我尝试

require 'date'

时遇到错误 - 没有要加载的文件 - date

当我尝试时 需要“mscorlib.dll” 我收到错误 - 没有要加载的此类文件 - mscorlib.dll

执行这些操作的正确方法是什么?

更新: 参见乔恩·斯基特的评论

When I embed IronRuby what is the proper way to get a reference to either Ruby's DateTime/Date classes or .NET's System.DateTime. I'm running into errors when I try

require 'date'

I get the error - no such file to load -- date

when I try
require 'mscorlib.dll'
I get the error - no such file to load -- mscorlib.dll

What is the right way to do either of these?

UPDATE:
see comments to Jon Skeet

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ぶ宁プ宁ぶ 2024-08-12 15:08:07

Time 是 ruby​​ 中的核心类型,它映射到 System.DateTime。

要获取 DateTime.Now 你可以这样做 Time.new

有日期时间扩展,所以你可以这样做
需要“时间”
或 require 'datetime'

mscorlib 是隐含的并且始终是必需的,因此您不需要明确要求它。
如果你想获取 CLR DateTime,你可以执行

System::DateTime.now 或 System::DateTime.Now

Time is a core type in ruby which maps to a System.DateTime.

To get DateTime.Now you can do Time.new

There are datetime extensions so you could do
require 'time'
or require 'datetime'

mscorlib is implied and is always required so you don't need to explicitly require it.
if you want to get to the CLR DateTime you can do

System::DateTime.now or System::DateTime.Now

始终不够爱げ你 2024-08-12 15:08:07

您是否尝试

require 'mscorlib'

指定程序集名称而不是文件名?这就是这篇旧博客文章中指定的内容。 。

Have you tried

require 'mscorlib'

to specify the assembly name instead of the filename? That's what's specified in this old blog post...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文