Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

The msdn documentation for SPFieldCollection.Item[String] says

Gets the field with the specified display name from the collection. In Microsoft C#, this property is an indexer for the SPFieldCollection class.

If we look at the documentation for Field.Title it says:

Gets or sets the display name for the field.

Hence we have two references to the term "display name", but when I try this:

foreach (SPField field in spWebInstance.Fields) {
    // using the field Title, i.e. the display name, to index
    // SPWeb.Fields, as per msdn documentation...
    Console.WriteLine(spWebInstance.Fields[field.Title]);
}

I get an exception stating that the given field cannot be found. Are the docs wrong, or what's going on here?

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.