Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Share .NET
>
Tutorial
> Get list by title
The following example shows you how to get list with title "List100".
C# example
using System; using System.Net; using System.Collections.Generic; using Independentsoft.Share; using Independentsoft.Share.QueryOptions; namespace Sample { class Program { static void Main(string[] args) { try { Service service = new Service("https://independentsoft.sharepoint.com", "username", "password"); IsEqualTo restriction = new IsEqualTo("Title", "List100"); Filter filter = new Filter(restriction); IList
queryOption = new List
(); queryOption.Add(filter); IList
lists = service.GetLists(queryOption); for (int i = 0; i < lists.Count; i++) { Console.WriteLine("Id: " + lists[i].Id); Console.WriteLine("Title: " + lists[i].Title); Console.WriteLine("Description: " + lists[i].Description); Console.WriteLine("------------------------------------"); } Console.Read(); } catch (ServiceException ex) { Console.WriteLine("Error: " + ex.Message); Console.WriteLine("Error: " + ex.ErrorCode); Console.WriteLine("Error: " + ex.ErrorString); Console.WriteLine("Error: " + ex.RequestUrl); Console.Read(); } catch (WebException ex) { Console.WriteLine("Error: " + ex.Message); Console.Read(); } } } }
VB example
Imports System Imports System.Net Imports Independentsoft.Share Imports Independentsoft.Share.QueryOptions Namespace Sample Class Module1 Shared Sub Main(ByVal args As String()) Try Dim service As New Service("https://independentsoft.sharepoint.com", "username", "password") Dim restriction As IsEqualTo = New IsEqualTo("Title", "List100") Dim filter As Filter = New Filter(restriction) Dim queryOption As IList(Of IQueryOption) = New List(Of IQueryOption) queryOption.Add(filter) Dim lists As IList(Of List) = service.GetLists(queryOption) For i As Integer = 0 To lists.Count - 1 Console.WriteLine("Id: " & lists(i).Id) Console.WriteLine("Title: " & lists(i).Title) Console.WriteLine("Description: " & lists(i).Description) Console.WriteLine("------------------------------------") Next Console.Read() Catch ex As ServiceException Console.WriteLine("Error: " + ex.Message) Console.WriteLine("Error: " + ex.ErrorCode) Console.WriteLine("Error: " + ex.ErrorString) Console.WriteLine("Error: " + ex.RequestUrl) Console.Read() Catch ex As WebException Console.WriteLine("Error: " + ex.Message) Console.Read() End Try End Sub End Class End Namespace
Need help? Ask our developers:
Name*
Email*
Message*