blob: 2bd707f3892fcd2122e16db86f4b9b70103d370d (
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'");
}
public static void Main()
{
Fun (new SomeStruct ());
}
}
|