blob: ac49ea85feddce252909a4f77bc20a46e60c24d9 (
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
|
public interface SomeInterface
{
int Foo { get; set; }
}
public struct SomeStruct : SomeInterface
{
int x;
public int Foo {
get { return x; }
set { x = value; }
}
}
public class Test
{
public static void Fun<T> (T t)
where T : SomeInterface
{
if (++t.Foo != 1)
throw new System.Exception ("not 1");
if (t.Foo != 1)
throw new System.Exception ("didn't update 't'");
}
static void Main()
{
Fun (new SomeStruct ());
}
}
|