Share via


Code Snippet: Implementing an IdEnumerator

Applies to: SharePoint Server 2010

In this article
Example for a .NET Connectivity Assembly
Example for an ASP.NET Web Service
Example for a WCF Service

The following code examples show how you can implement a IdEnumerator method instance in a .NET connectivity assembly and in a Web service.

Example for a .NET Connectivity Assembly

public String[] GetCustomerIDs()
{
    string[] customerIDs = new string[customers.Count];

    for (int i = 0; i < customers.Count; i++)
    {
        if (!customers[i].IsDeleted)
            customerIDs[i] = customers[i].CustomerID;
    }
    return customerIDs;
}

Example for an ASP.NET Web Service

[WebMethod]
public String[] GetCustomerIDs()
{
    string[] customerIDs = new string[customers.Count];

    for (int i = 0; i < customers.Count; i++)
    {
        if (!customers[i].IsDeleted)
            customerIDs[i] = customers[i].CustomerID;
    }
    return customerIDs;
}

Example for a WCF Service

The following code shows the operation definition in the service contract interface.

[OperationContract]
string[] GetCustomerIDs();

The following example shows the implementation of the method instance.

public String[] GetCustomerIDs()
{
    string[] customerIDs = new string[customers.Count];

    for (int i = 0; i < customers.Count; i++)
    {
        if (!customers[i].IsDeleted)
            customerIDs[i] = customers[i].CustomerID;
    }
    return customerIDs;
}

See Also

Concepts

Implementing an IdEnumerator