共用方式為


MessageQueuePermissionEntryCollection.IndexOf 方法

定義

判斷在這個集合中的指定使用權限項目索引。

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

參數

value
MessageQueuePermissionEntry

要搜尋的使用權限項目。

傳回

指定使用權限項目的以零起始索引,或 -1 (如果在集合中找不到使用權限項目)。

範例

下列程式碼範例示範 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));

適用於