Partager via


MessageQueuePermissionEntryCollection.Item[Int32] Propriété

Définition

Obtient ou définit l'objet à l'index spécifié.

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

Paramètres

index
Int32

Index de base zéro dans la collection.

Valeur de propriété

MessageQueuePermissionEntry existant à l'index spécifié.

Exemples

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

S’applique à