4
F#中的type Something()
和type Something
有什么区别?F#:有括号和不带括号的类型之间的区别
为什么这个片段在ASP.NET Core 1.0 F# project作品引用:
open System
open Microsoft.AspNetCore.Hosting
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Hosting
open Microsoft.AspNetCore.Http
type Startup() =
member this.Configure(app: IApplicationBuilder) =
app.Run(fun context -> context.Response.WriteAsync("Hello from ASP.NET Core!"))
[<EntryPoint>]
let main argv =
let host = WebHostBuilder().UseKestrel().UseStartup<Startup>().Build()
host.Run()
printfn "Server finished!"
0
但这种失败:
open System
open Microsoft.AspNetCore.Hosting
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Hosting
open Microsoft.AspNetCore.Http
type Startup =
member this.Configure(app: IApplicationBuilder) =
app.Run(fun context -> context.Response.WriteAsync("Hello from ASP.NET Core!"))
[<EntryPoint>]
let main argv =
let host = WebHostBuilder().UseKestrel().UseStartup<Startup>().Build()
host.Run()
printfn "Server finished!"
0
不同的类型都是通过F#中的'type'关键字定义的,包括类型别名,DU,记录,类等等。不同的参数将指出你正在创建什么类型的类型。 [介绍F#类型:](http://fsharpforfunandprofit.com/series/understanding-fsharp-types.html) – s952163