This documentation is archived and is not being maintained.
ImportCollection.IndexOf Method
.NET Framework 1.1
Searches for the specified Import and returns the zero-based index of the first occurrence within the collection.
[Visual Basic] Public Function IndexOf( _ ByVal import As Import _ ) As Integer [C#] public int IndexOf( Import import ); [C++] public: int IndexOf( Import* import ); [JScript] public function IndexOf( import : Import ) : int;
Parameters
- import
- The Import for which to search in the collection.
Return Value
A 32-bit signed integer.
Example
[Visual Basic, C#, C++] The following example demonstrates the use of the IndexOf method.
[Visual Basic] ' Get Import by Index. Dim myImport As Import = _ myServiceDescription.Imports(myServiceDescription.Imports.Count - 1) Console.WriteLine("Import by Index...") If myImportCollection.Contains(myImport) Then Console.WriteLine("Import Namespace '" + myImport.Namespace + _ "' is found in 'ImportCollection'.") Console.WriteLine("Index of '" + myImport.Namespace + _ "' in 'ImportCollection' = " + _ myImportCollection.IndexOf(myImport).ToString()) Console.WriteLine("Delete Import from 'ImportCollection'...") myImportCollection.Remove(myImport) If myImportCollection.IndexOf(myImport) = - 1 Then Console.WriteLine("Import is successfully removed from Import Collection.") End If [C#] // Get Import by Index. Import myImport = myServiceDescription.Imports[myServiceDescription.Imports.Count-1]; Console.WriteLine("Import by Index..."); if (myImportCollection.Contains(myImport)) { Console.WriteLine("Import Namespace '" + myImport.Namespace + "' is found in 'ImportCollection'."); Console.WriteLine("Index of '" + myImport.Namespace + "' in 'ImportCollection' = " + myImportCollection.IndexOf(myImport)); Console.WriteLine("Deleting Import from 'ImportCollection'..."); myImportCollection.Remove(myImport); if(myImportCollection.IndexOf(myImport) == -1) Console.WriteLine("Import is successfully removed from Import Collection."); } [C++] // Get Import by Index. Import * myImport = myServiceDescription->Imports->Item[myServiceDescription->Imports->Count-1]; Console::WriteLine(S"Import by Index..."); if (myImportCollection->Contains(myImport)) { Console::WriteLine(S"Import Namespace ' {0} ' is found in 'ImportCollection'.", myImport -> Namespace); Console::WriteLine(S"Index of '{0}' in 'ImportCollection' = {1}", myImport -> Namespace, __box(myImportCollection->IndexOf(myImport))); Console::WriteLine(S"Deleting Import from 'ImportCollection'..."); myImportCollection->Remove(myImport); if (myImportCollection->IndexOf(myImport) == -1) Console::WriteLine(S"Import is successfully removed from Import Collection."); }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
ImportCollection Class | ImportCollection Members | System.Web.Services.Description Namespace
Show: