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?