In SharePoint, I’d like to be able to check if a particular List or ListItem exists before performing operations on it, but there doesn’t seem to be a way to do this without simply catching an ArgumentException. Surely there’s a better way?
Share
To find an instance of a SPList you could use a linq solution:
A similar solution could be made for find an instance of a SPListItem
FirstOrDefault is the trick. Default is null (not an exception).
UPDATE:
as a comment, this line of code:
is the same as writing