C# SortedSet CopyTo(T[], Int32)

Description

SortedSet CopyTo(T[], Int32) copies the complete SortedSet to a compatible one-dimensional array, starting at the specified array index.

Syntax

SortedSet.CopyTo(T[], Int32) has the following syntax.


public void CopyTo(
  T[] array,
  int index
)

Parameters

SortedSet.CopyTo(T[], Int32) has the following parameters.

  • array - A one-dimensional array that is the destination of the elements copied from the SortedSet . The array must have zero-based indexing.
  • index - The zero-based index in array at which copying begins.

Returns

SortedSet.CopyTo(T[], Int32) method returns

Example


using System;// www  .j a v  a2  s  .  c o m
using System.Collections.Generic;

public class MainClass
{
    public static void Main(String[] argv)
    {
        SortedSet<int> evenNumbers = new SortedSet<int>();
        for (int i = 0; i < 5; i++)
        {
            evenNumbers.Add(i * 2);
        }
        int[] intArray = new int[5];
        evenNumbers.CopyTo(intArray, 0);

    }
}




















Home »
  C# Tutorial »
    System.Collections.Generic »




HashSet
LinkedList
LinkedListNode
List
Queue
SortedSet
Stack