Copy HashSet to an array, starting at the specified array index in CSharp
Description
The following code shows how to copy HashSet to an array, starting at the specified array index.
Example
/* w w w . ja v a 2 s . c o m*/
using System;
using System.Collections.Generic;
public class MainClass
{
public static void Main(String[] argv)
{
HashSet<int> evenNumbers = new HashSet<int>();
for (int i = 0; i < 5; i++)
{
evenNumbers.Add(i * 2);
}
int[] intArray = new int[5];
evenNumbers.CopyTo(intArray, 1);
foreach(int i in intArray){
Console.WriteLine(i);
}
}
}