Frank Hale
Frank Hale

Reputation: 1896

F# - how do I index a collection (specifically the PropertyCollection)

I'm trying to wrap my mind around F# so I thought it would be fun to convert some simple C# code that I have that looks a user up in Active Directory using System.DirectoryServices namespace and returns a DirectoryEntry object. The part I'm struggling with is indexing the PropertyCollection that is contained in the DirectoryEntry.

In C# once I have the DirectoryEntry I can get at properties in the PropertyCollection by doing this:

entry.Properties["displayName"].Value

I'm currently struggling with how to index the collection in F#. Can somebody shed some light on this?

Upvotes: 3

Views: 334

Answers (1)

JaredPar
JaredPar

Reputation: 754585

You need to add a . before the brackets.

entry.Properties.["displayName"].Value

Coming from a C++ / C# background I found the syntax is a bit odd at first but you get used to it.

Upvotes: 7

Related Questions