blob: f513eeeb03358f4bc6aa7a50716d3bd326c54390 (
plain)
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
|
// We create an instance of a type parameter which has the new() constraint.
using System;
public class Foo<T>
where T : new ()
{
public T Create ()
{
return new T ();
}
}
class X
{
public X ()
{ }
void Hello ()
{
Console.WriteLine ("Hello World");
}
public static void Main ()
{
Foo<X> foo = new Foo<X> ();
foo.Create ().Hello ();
}
}
|