DiscoveryReferenceCollection.Item Property
.NET Framework 3.0
Gets or sets the DiscoveryReference at the specified index.
Namespace: System.Web.Services.Discovery
Assembly: System.Web.Services (in system.web.services.dll)
Assembly: System.Web.Services (in system.web.services.dll)
public: property DiscoveryReference^ default [int] { DiscoveryReference^ get (int i); void set (int i, DiscoveryReference^ value); }
/** @property */ public DiscoveryReference get_Item (int i) /** @property */ public void set_Item (int i, DiscoveryReference value)
Not applicable.
Parameters
- i
The zero-based index of the DiscoveryReference to get or set.
Property Value
The DiscoveryReference at the specified index.| Exception type | Condition |
|---|---|
|
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 ); }
class MyDiscoveryDocumentClass
{
public static void main(String[] args) throws Exception
{
DiscoveryDocumentReference myDiscoveryDocReference1 =
new DiscoveryDocumentReference();
DiscoveryDocumentReference myDiscoveryDocReference2 =
new DiscoveryDocumentReference();
DiscoveryReference myDiscoveryReference;
Console.WriteLine("Demonstrating DiscoveryReferenceCollection class.");
// Create new DiscoveryReferenceCollection.
DiscoveryReferenceCollection myDiscoveryReferenceCollection =
new DiscoveryReferenceCollection();
// Access the Count method.
Console.WriteLine("The number of elements in the collection is: "
+ ((Int32)myDiscoveryReferenceCollection.get_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: "
+ ((Int32)myDiscoveryReferenceCollection.get_Count()).ToString());
// Call the Contains method.
if (myDiscoveryReferenceCollection.
Contains(myDiscoveryDocReference1) != true) {
throw new Exception("Element not found in collection.");
}
// Access the indexed member.
myDiscoveryReference = (DiscoveryReference)
myDiscoveryReferenceCollection.get_Item(0);
if (myDiscoveryReference == null) {
throw new 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: "
+ ((Int32)myDiscoveryReferenceCollection.get_Count()).ToString());
} //main
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: