다음을 통해 공유


MessageQueuePermissionEntryCollection.CopyTo 메서드

정의

배열의 특정 인덱스에서 시작하여 이 컬렉션에서 배열로 사용 권한 항목을 복사합니다.

public:
 void CopyTo(cli::array <System::Messaging::MessageQueuePermissionEntry ^> ^ array, int index);
public void CopyTo (System.Messaging.MessageQueuePermissionEntry[] array, int index);
member this.CopyTo : System.Messaging.MessageQueuePermissionEntry[] * int -> unit
Public Sub CopyTo (array As MessageQueuePermissionEntry(), index As Integer)

매개 변수

array
MessageQueuePermissionEntry[]

이 컬렉션의 사용 권한 항목을 받는 MessageQueuePermissionEntry 형식의 배열입니다.

index
Int32

사용 권한 항목의 복사를 시작할 인덱스(0부터 시작)입니다.

예제

다음 코드 예제에서는 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();
// 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);

// Create an array of type MessageQueuePermissionEntry.
MessageQueuePermissionEntry[] entries =
    new 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.ToString());

적용 대상