1 using System
.Collections
.Generic
;
3 public class ClassA
{};
4 public class ClassB
{};
6 public struct GenStruct
<T
> {
14 public static T
getDefault () {
18 public static GenStruct
<T
> getDefaultStruct () {
19 return default (GenStruct
<T
>);
24 public static bool isDefaultStruct
<T
> (GenStruct
<T
> gs
) {
25 EqualityComparer
<T
> eq
= EqualityComparer
<T
>.Default
;
27 return gs
.field1
== 0 && eq
.Equals (gs
.field2
, default (T
)) && gs
.field3
== 0 && gs
.field4
== 0;
30 public static int Main () {
31 if (Gen
<ClassA
>.getDefault () != null)
33 if (Gen
<ClassB
>.getDefault () != null)
35 if (Gen
<int>.getDefault () != 0)
37 if (!isDefaultStruct
<ClassA
> (Gen
<ClassA
>.getDefaultStruct ()))
39 if (!isDefaultStruct
<ClassB
> (Gen
<ClassB
>.getDefaultStruct ()))
41 if (!isDefaultStruct
<int> (Gen
<int>.getDefaultStruct ()))