1 using System
.Collections
.Generic
;
7 public struct GenStruct
<T
> {
11 public GenStruct (T _t
, int _field
) {
16 public bool isEqualTo (GenStruct
<T
> gs
) {
17 EqualityComparer
<T
> comp
= EqualityComparer
<T
>.Default
;
19 return comp
.Equals(gs
.t
, t
) && gs
.field
== field
;
23 public class GenClass
<T
> {
24 public object boxStruct (GenStruct
<T
> gs
) {
29 public object boxNullableStruct (GenStruct<T>? gs) {
36 public static int Main () {
37 GenClass
<int> gci
= new GenClass
<int> ();
38 GenStruct
<int> gsi
= new GenStruct
<int> (123, 456);
40 if (!gsi
.isEqualTo ((GenStruct
<int>)gci
.boxStruct (gsi
)))
43 if (!gsi.isEqualTo ((GenStruct<int>)gci.boxNullableStruct (gsi)))
45 if (gci.boxNullableStruct (null) != null)
49 GenClass
<ClassA
> gca
= new GenClass
<ClassA
> ();
50 GenStruct
<ClassA
> gsa
= new GenStruct
<ClassA
> (new ClassA (), 789);
52 if (!gsa
.isEqualTo ((GenStruct
<ClassA
>)gca
.boxStruct (gsa
)))
55 if (!gsa.isEqualTo ((GenStruct<ClassA>)gca.boxNullableStruct (gsa)))
57 if (gca.boxNullableStruct (null) != null)
61 UnboxerStruct
<ClassA
> us
;
62 Boxer
<ClassA
> b
= new Boxer
<ClassA
> ();
66 if (((UnboxerStruct
<ClassA
>?)b
.boxNullable (us
)).Value
.field
!= 123)
68 if (b
.boxNullable (null) != null)