Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

MessageQueuePermissionEntryCollection::CopyTo Method (array<MessageQueuePermissionEntry^>^, Int32)

 

Copies the permission entries from this collection to an array, starting at a particular index of the array.

Namespace:   System.Messaging
Assembly:  System.Messaging (in System.Messaging.dll)

public:
void CopyTo(
	array<MessageQueuePermissionEntry^>^ array,
	int index
)

Parameters

array
Type: array<System.Messaging::MessageQueuePermissionEntry^>^

An array of type MessageQueuePermissionEntry that receives this collection's permission entries.

index
Type: System::Int32

The zero-based index at which to begin copying the permission entries.

The following code example demonstrates the use of CopyTo.

// 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);

// Create an array of type MessageQueuePermissionEntry.
array<MessageQueuePermissionEntry^>^ entries = 
    gcnew array<MessageQueuePermissionEntry^>(1);

// Copy the collection to index 0 of the array.
collection->CopyTo(entries, 0);

// Show that the array now contains the entry.
Console::WriteLine("entries[0].PermissionAccess: {0}",
    entries[0]->PermissionAccess);
Console::WriteLine("entries[0].MachineName: {0}",
    entries[0]->MachineName);
Console::WriteLine("entries[0].Label: {0}", entries[0]->Label);
Console::WriteLine("entries[0].Category: {0}",
    entries[0]->Category);

queue->Close();

.NET Framework
Available since 1.1
Return to top
Show:
© 2017 Microsoft