Comparteix a través de


MessageQueuePermissionEntryCollection.IndexOf Método

Definición

Determina el índice de una entrada de permiso especificada en esta colección.

public:
 int IndexOf(System::Messaging::MessageQueuePermissionEntry ^ value);
public int IndexOf (System.Messaging.MessageQueuePermissionEntry value);
member this.IndexOf : System.Messaging.MessageQueuePermissionEntry -> int
Public Function IndexOf (value As MessageQueuePermissionEntry) As Integer

Parámetros

value
MessageQueuePermissionEntry

Entrada de permiso que se va a buscar.

Devoluciones

Índice de base cero de la entrada de permiso especificada, o -1 si la entrada de permiso no se ha encontrado en la colección.

Ejemplos

En el siguiente ejemplo de código se muestra el uso de IndexOf.

// Connect to a queue on the local computer.
MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue");

// Create a new instance of MessageQueuePermission.
MessageQueuePermission^ permission = gcnew MessageQueuePermission();

// Get an instance of MessageQueuePermissionEntryCollection from the
// permission's PermissionEntries property.
MessageQueuePermissionEntryCollection^ collection =
    permission->PermissionEntries;

// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry(
    MessageQueuePermissionAccess::Receive, 
    queue->MachineName, 
    queue->Label, 
    queue->Category.ToString());

// Add the entry to the collection.
collection->Add(entry);

// Display the index of the entry in the collection.
Console::WriteLine("Collection contains entry at index: {0}",
    collection->IndexOf(entry));

queue->Close();
// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");

// Create a new instance of MessageQueuePermission.
MessageQueuePermission permission = new MessageQueuePermission();

// Get an instance of MessageQueuePermissionEntryCollection from the
// permission's PermissionEntries property.
MessageQueuePermissionEntryCollection collection =
    permission.PermissionEntries;

// Create a new instance of MessageQueuePermissionEntry.
MessageQueuePermissionEntry entry = new MessageQueuePermissionEntry(
    MessageQueuePermissionAccess.Receive,
    queue.MachineName,
    queue.Label,
    queue.Category.ToString());

// Add the entry to the collection.
collection.Add(entry);

// Display the index of the entry in the collection.
Console.WriteLine("Collection contains entry at index: {0}",
    collection.IndexOf(entry));

Se aplica a