MessageQueuePermissionEntryCollection.IndexOf Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Determines the index of a specified permission entry in this 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
Parameters
The permission entry to search for.
Returns
The zero-based index of the specified permission entry, or -1 if the permission entry was not found in the collection.
Examples
The following code example demonstrates the use of 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));
Applies to
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.