DiscoveryReferenceCollection.Item Property (Int32)

 

Gets or sets the DiscoveryReference at the specified index.

Namespace:   System.Web.Services.Discovery
Assembly:  System.Web.Services (in System.Web.Services.dll)

Public Property Item (
	i As Integer
) As DiscoveryReference

Parameters

i
Type: System.Int32

The zero-based index of the DiscoveryReference to get or set.

Property Value

Type: System.Web.Services.Discovery.DiscoveryReference

The DiscoveryReference at the specified index.

Exception Condition
ArgumentOutOfRangeException

i is not a valid index in the DiscoveryReferenceCollection.

Class MyDiscoveryDocumentMod

   Shared Sub Main()
   Try
      Dim myDiscoveryDocReference1 As New DiscoveryDocumentReference()
      Dim myDiscoveryDocReference2 As New DiscoveryDocumentReference()
      Dim myDiscoveryReference As DiscoveryReference

      Console.WriteLine("Demonstrating DiscoveryReferenceCollection class.")

      ' Create new DiscoveryReferenceCollection.
      Dim myDiscoveryReferenceCollection As New DiscoveryReferenceCollection()

      ' Access the Count method.
      Console.WriteLine("The number of elements in collection is: " & _
         myDiscoveryReferenceCollection.Count.ToString())

      ' Add elements to the collection.
      myDiscoveryReferenceCollection.Add(myDiscoveryDocReference1)
      myDiscoveryReferenceCollection.Add(myDiscoveryDocReference2)

      Console.WriteLine("The number of elements in the collection " _
         & "after adding two elements to the collection: " _
         & myDiscoveryReferenceCollection.Count.ToString())

      ' Call the Contains method.
      If myDiscoveryReferenceCollection.Contains(myDiscoveryDocReference1) _
         <> True Then
         Throw New Exception("Element not found in collection.")
      End If

      ' Access the Item property.
      myDiscoveryReference = myDiscoveryReferenceCollection.Item(0)

      If  myDiscoveryReference Is Nothing Then
         Throw New Exception("Element not found in collection.")
      End If

      ' Remove one element from the collection.
      myDiscoveryReferenceCollection.Remove(myDiscoveryDocReference1)
      Console.WriteLine("The number of elements in collection " _
         & "after removing one element is: " _
         & myDiscoveryReferenceCollection.Count.ToString())

   Catch e As Exception
       Console.Writeline("Exception occured : " + e.Message)
   End Try
   End Sub

End Class

.NET Framework
Available since 1.1
Return to top
Show: