blob: 786eead37ea9766d198326af56fee11f26b57dda (
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
29
30
31
32
33
34
35
36
37
38
|
using System;
static class Program
{
public interface I1
{
string Id { get; }
}
public class BaseClass
{
public int Id {
get {
return 4;
}
}
}
public class Derived : BaseClass, I1
{
public new string Id {
get {
return "aa";
}
}
}
static void Generic<T> (T item) where T : BaseClass, I1
{
if (item.Id != 4)
throw new Exception ("Doom!");
}
static void Main ()
{
Generic (new Derived ());
}
}
|