-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayICollectionMethods.cs
More file actions
46 lines (37 loc) · 991 Bytes
/
Copy pathArrayICollectionMethods.cs
File metadata and controls
46 lines (37 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
public static class Program {
public static void Main(string[] args)
{
var array = new[]
{new TestClass(0), new TestClass(1), new TestClass(2), new TestClass(3), new TestClass(4), new TestClass(5)};
TestCollectionMethod<TestClass>(array);
TestCollectionMethod<Object>(array);
}
public static void TestCollectionMethod<T>(ICollection<T> input)
{
var targetArray = new T[8];
input.CopyTo(targetArray, 2);
foreach (var testClass in targetArray)
{
if (testClass != null)
Console.WriteLine(testClass);
else
{
Console.WriteLine("null");
}
}
}
}
public class TestClass
{
public int Value { get; private set; }
public TestClass(int value)
{
Value = value;
}
public override string ToString()
{
return Value.ToString();
}
}