This documentation is archived and is not being maintained.

DiscoveryReferenceCollection::Item Property

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 DiscoveryReference^ Item[int i] {
	DiscoveryReference^ get (int i);
	void set (int i, DiscoveryReference^ value);
}

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.

ExceptionCondition
ArgumentOutOfRangeException

i is not a valid index in the DiscoveryReferenceCollection.


int main()
{
   DiscoveryDocumentReference^ myDiscoveryDocReference1 = gcnew DiscoveryDocumentReference;
   DiscoveryDocumentReference^ myDiscoveryDocReference2 = gcnew DiscoveryDocumentReference;
   DiscoveryReference^ myDiscoveryReference;
   Console::WriteLine( "Demonstrating DiscoveryReferenceCollection class." );

   // Create new DiscoveryReferenceCollection.
   DiscoveryReferenceCollection^ myDiscoveryReferenceCollection = gcnew DiscoveryReferenceCollection;

   // Access the Count method.
   Console::WriteLine( "The number of elements in the collection is: {0}", myDiscoveryReferenceCollection->Count );

   // 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: {0}", myDiscoveryReferenceCollection->Count );

   // Call the Contains method.
   if ( myDiscoveryReferenceCollection->Contains( myDiscoveryDocReference1 ) != true )
   {
      throw gcnew Exception( "Element not found in collection." );
   }

   // Access the indexed member.
   myDiscoveryReference = dynamic_cast<DiscoveryReference^>(myDiscoveryReferenceCollection[ 0 ]);
   if ( myDiscoveryReference == nullptr )
   {
      throw gcnew Exception( "Element not found in collection." );
   }

   // Remove one element from collection.
   myDiscoveryReferenceCollection->Remove( myDiscoveryDocReference1 );
   Console::WriteLine( "The number of elements in the collection after removing one element is: {0}", myDiscoveryReferenceCollection->Count );
}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: