简体   繁体   中英

Why can't F# open static classes?

I thought modules were compiled to static class .NET IL code. I can open namespaces and modules, but why not static classes?

printfn "Hello, World!"

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

This is now supported, starting with the F# 5 release :

open type System.Console

WriteLine "Hello World!"

There is a suggestion for it on GitHub . The original suggestion , has a comment from 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.

I would recommend voting for the issue on GitHub (react with a thumbs up). If you have any comment to add then people may become interested in this again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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