Partager via


MessageQueuePermissionEntryCollection.IndexOf Méthode

Définition

Détermine l'index d'une entrée d'autorisation spécifiée dans cette collection.

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

Paramètres

value
MessageQueuePermissionEntry

Entrée d'autorisation à rechercher.

Retours

Index de base zéro de l'entrée d'autorisation spécifiée, ou -1 si l'entrée d'autorisation est introuvable dans la collection.

Exemples

L'exemple de code suivant montre l'utilisation 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));

S’applique à