Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?
share|improve this question

1 Answer 1

up vote 1 down vote accepted

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

if (value is SPFieldLookupValue) {}
share|improve this answer

Your Answer

 
discard

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

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