Namespace GenericsTest

Class Foo<T>
Public
	Function GetTypeName( t As T ) As String
		Return t.GetType().Name
	End Function
End Class
Class Bar<T>
	Inherits Foo<String>
End Class

Sub TestMain()
	' クラス型の型パラメータ
	Dim a = New System.Collections.Generic.List<String>
	a.Add( "test" )
	a.Add( "123" )
	UnitTest( "Generic ... type parameter is class", a[0] = "test" and a[1] = "123" )

	' 値型の型パラメータ
	Dim b = New System.Collections.Generic.List<Byte>
	b.Add( 123 )
	b.Add( 234 )
	UnitTest( "Generic ... type parameter is value(byte)", b[0] = 123 and b[1] = 234 )
	Dim c = New System.Collections.Generic.List<Double>
	c.Add( 123.456 )
	c.Add( 456.789 )
	UnitTest( "Generic ... type parameter is value(double)", c[0] = 123.456 and c[1] = 456.789 )

	' 型パラメータがクロスした場合
	' TODO: より多くのパターンで試す必要あり
	Dim bar = New Bar<Long>
	UnitTest( "Generic ... complex", bar.GetTypeName( New String() ), "String" )
End Sub

End Namespace

GenericsTest.TestMain()
