I had expected that if TryGetFieldByStaticName succeeds and returns a value, there would be an SPField in the item that has a static name equal to what I used in the TryGet... call, but no? I.e. can someone explain why the following piece of code outputs Value: a field value bot not here it is.
// page is SPListItem from Pages list
string stName = "CustomName";
try {
Console.WriteLine("Value: " + page.Fields.TryGetFieldByStaticName(stName));
foreach (SPField field in page.Fields) {
if (field.StaticName.Equals(stName)) {
Console.WriteLine("here it is");
}
}
} catch (Exception ex) {
Console.WriteLine("Not Found");
}
