我注意到管道通向/来自某些.NET方法的困难。玩具例如与#net对象管道连接的F#
let foo = System.String [| 'a'; 'b'; 'c' |] // works
let foo = [| 'a'; 'b'; 'c' |] |> System.String // fails
// error FS0802: Invalid use of a type name and/or object constructor.
let foo = System.String <| [| 'a'; 'b'; 'c' |] // fails the same way
let foo = [| 'a'; 'b'; 'c' |] |> new System.String // Fails
// error FS0010: Incomplete structured construct at or before this point in expression
基本上,我想弄清楚的时候,你可以用.NET对象,当不结合管道。如果有参考,我很乐意获得链接!
你的例子(除了最后一个,这是非法的语法)在F#4中工作。他们[增加了支持将构造函数视为函数](https://blogs.msdn.microsoft.com/fsharpteam/2014/11/ 12 /宣布-A-预览-F-4-0的 - 和 - 的视觉-F-工具 - 在-VS-2015 /)。您使用的是哪个版本的F#? –
我正在运行Microsoft(R)F#交互版本11.0.60610.1 版权所有(c)Microsoft Corporation。版权所有。 – user1443098
是的,这是一个非常旧的版本,F#4有交互式版本14,所以我猜你正在使用F#3(可能甚至是老一些)......无论如何,无论你升级到至少Visual Studio 2015还是你有如链接的博客文章中所述,使用'|> fun chars - > System.String chars' lambdas。 –