# CopyTo

> Copies all collected samples to the destination list.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Profiling](/engine/6000.0/script-reference/unity/profiling.md)
* **Assembly:** UnityEngine.CoreModule

## CopyTo(List\<ProfilerRecorderSample>, bool)

Copies all collected samples to the destination list.

```csharp
public void CopyTo(List<ProfilerRecorderSample> outSamples, bool reset = false)
```

### Parameters

**** (\[List\<ProfilerRecorderSample>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): Destination list.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Reset ProfilerRecorder.

## CopyTo(ProfilerRecorderSample\*, int, bool)

Copies collected samples to the destination array.

```csharp
public int CopyTo(ProfilerRecorderSample* dest, int destSize, bool reset = false)
```

### Parameters

**** (\[ProfilerRecorderSample\*]\(/engine/6000.0/script-reference/unity/profiling/profilerrecordersample)): Pointer to the destination samples array.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Destination samples array size.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Reset ProfilerRecorder.

### Returns

| Type                                                       | Description                               |
| ---------------------------------------------------------- | ----------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | Returns the count of the copied elements. |

### Examples

```csharp
using Unity.Profiling;

public class ExampleScript
{
    static double GetRecorderFrameAverage(ProfilerRecorder recorder)
    {
        var samplesCount = recorder.Capacity;
        if (samplesCount == 0)
            return 0;

        double r = 0;
        unsafe
        {
            var samples = stackalloc ProfilerRecorderSample[samplesCount];
            recorder.CopyTo(samples, samplesCount);
            for (var i = 0; i < samplesCount; ++i)
                r += samples[i].Value;
            r /= samplesCount;
        }

        return r;
    }
}
```
