简体   繁体   English

为什么 F# 不能打开静态类?

[英]Why can't F# open static classes?

I thought modules were compiled to static class .NET IL code.我认为模块被编译为静态类 .NET IL 代码。 I can open namespaces and modules, but why not static classes?我可以open名称空间和模块,但为什么不能打开静态类?

printfn "Hello, World!"

open System.Console
WriteLn("Hello, World!")

This is now supported, starting with the F# 5 release :现在支持, 从 F# 5 版本开始

open type System.Console

WriteLine "Hello World!"

There is a suggestion for it on GitHub . GitHub 上有一个建议。 The original suggestion , has a comment from Don Syme: 最初的建议有 Don Syme 的评论:

Yes, this should I suppose be implemented to match the corresponding C# feature, since static classes will begin to be more common coming from the C# world.是的,我认为这应该被实现以匹配相应的 C# 功能,因为静态类将开始从 C# 世界中变得更加普遍。

I would recommend voting for the issue on GitHub (react with a thumbs up).我建议在 GitHub 上对该问题进行投票(竖起大拇指作为回应)。 If you have any comment to add then people may become interested in this again.如果您有任何评论要添加,那么人们可能会再次对此感兴趣。

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

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