F# - 如何索引集合(特别是PropertyCollection)

Fra*_*ale 3 f# active-directory

我试图围绕F#进行思考,所以我认为使用System.DirectoryServices命名空间转换一些在Active Directory中看起来像用户的简单C#代码并返回DirectoryEntry对象会很有趣.我正在努力的部分是索引DirectoryEntry中包含的PropertyCollection.

在C#中,有了DirectoryEntry,我可以通过这样做获取PropertyCollection中的属性:

entry.Properties["displayName"].Value
Run Code Online (Sandbox Code Playgroud)

我目前正在努力解决如何在F#中索引集合的问题.有人可以对此有所了解吗?

Jar*_*Par 7

您需要.在括号前添加一个.

entry.Properties.["displayName"].Value
Run Code Online (Sandbox Code Playgroud)

来自C++/C#背景我发现语法起初有点奇怪,但你已经习惯了.