小编Las*_*all的帖子

匹配F#中的数组

我想在命令行参数数组上进行模式匹配.

我想要做的是有一个案例匹配任何至少有一个或多个参数的情况,并将第一个参数放在一个变量中,然后让另一个案例在没有参数时进行处理.

match argv with
    | [| first |] -> // this only matches when there is one
    | [| first, _ |] -> // this only matches when there is two
    | [| first, tail |] -> // not working
    | argv.[first..] -> // this doesn't compile
    | [| first; .. |] -> // this neither
    | _ -> // the other cases
Run Code Online (Sandbox Code Playgroud)

f#

4
推荐指数
2
解决办法
981
查看次数

使用Owin中间件进行Active Directory身份验证的ASP.Net MVC

我需要创建一个ASP.NET MVC 5应用程序,它将使用表单(如使用单个用户帐户)进行登录,但不使用数据库中的用户信息,而是使用Windows/AD帐户和凭据.

换句话说,比如使用Windows身份验证但使用html表单而不是弹出Windows身份验证通常会显示.这可能吗?

理想情况下,身份验证将降级到IIS并使用相同的协议,并根据角色允许或拒绝用户.

我怎样才能做到这一点?

我需要在web.config中配置什么?

我需要在Startup.Auth.cs中拥有什么?

.net c# asp.net-mvc

3
推荐指数
1
解决办法
3347
查看次数

定义F#函数但不调用它,函数似乎仍然被调用

在下面的代码中,为什么printStatement调用该函数?

module Tests

let printStatement =
    printfn "%s" "statement"

let functionCallingPrintStatement =
    printStatement

let functionNotCallingPrintStatement =
    printfn "%s" "This is a test"
Run Code Online (Sandbox Code Playgroud)

如果我打电话给functionNotCallingPrintStatement我的主程序?

open Tests

[<EntryPoint>]
let main argv =
    functionNotCallingPrintStatement     
    0 
Run Code Online (Sandbox Code Playgroud)

这是输出:

声明

这是一个测试

如果我将功能更改functionNotCallingPrintStatement为:

let functionNotCallingPrintStatement =
    ()
Run Code Online (Sandbox Code Playgroud)

第一个陈述被压制.

f#

-2
推荐指数
1
解决办法
61
查看次数

标签 统计

f# ×2

.net ×1

asp.net-mvc ×1

c# ×1