I have a SPListItem, with different fields (string, lookup, etc), that I have to iterate them and do different actions depending of the type.

How can I detect if value is type String or type Lookup?

  value = spListItem["nameField"];  // is string or lookup?

2 Answers 2


You can simply use the C# is operation. Ie.

if (value is SPFieldLookupValue) {}

try this

string tipoCampo = itemCollection.Fields[ColumnsAssignation.ComboText].TypeAsString;
if (tipoCampo == "Lookup") {}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.