SPListCollection.TryGetList Method

Returns the list with the specified title from the collection, but returns a null reference (Nothing in Visual Basic) instead of an exception if the list does not exist.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online


Public Function TryGetList ( _
    listTitle As String _
) As SPList
Dim instance As SPListCollection
Dim listTitle As String
Dim returnValue As SPList

returnValue = instance.TryGetList(listTitle)
public SPList TryGetList(
    string listTitle


  • listTitle
    Type: System.String

    A string that contains the title of the list.

Return Value

Type: Microsoft.SharePoint.SPList
An SPList object that represents the list.

See Also


SPListCollection Class

SPListCollection Members

Microsoft.SharePoint Namespace