Condividi tramite


MessageQueuePermissionEntryCollection.Item[Int32] Proprietà

Definizione

Ottiene o imposta l'oggetto in corrispondenza dell'indice specificato.

public:
 property System::Messaging::MessageQueuePermissionEntry ^ default[int] { System::Messaging::MessageQueuePermissionEntry ^ get(int index); void set(int index, System::Messaging::MessageQueuePermissionEntry ^ value); };
public System.Messaging.MessageQueuePermissionEntry this[int index] { get; set; }
member this.Item(int) : System.Messaging.MessageQueuePermissionEntry with get, set
Default Public Property Item(index As Integer) As MessageQueuePermissionEntry

Parametri

index
Int32

Indice in base zero dell'insieme.

Valore della proprietà

Oggetto MessageQueuePermissionEntry esistente in corrispondenza dell'indice specificato.

Esempio

L'esempio di codice seguente illustra l'uso di Item[].

// 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 entry's properties, using the collection's Item
// accessor.
Console::WriteLine("collection[0].PermissionAccess: {0}",
    collection[0]->PermissionAccess);
Console::WriteLine("collection[0].MachineName: {0}",
    collection[0]->MachineName);
Console::WriteLine("collection[0].Label: {0}", collection[0]->Label);
Console::WriteLine("collection[0].Category: {0}",
    collection[0]->Category);

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 entry's properties, using the collection's Item
// accessor.
Console.WriteLine("collection[0].PermissionAccess: {0}",
    collection[0].PermissionAccess);
Console.WriteLine("collection[0].MachineName: {0}",
    collection[0].MachineName);
Console.WriteLine("collection[0].Label: {0}", collection[0].Label);
Console.WriteLine("collection[0].Category: {0}",
    collection[0].Category.ToString());

Si applica a