我如何在VB.NET中执行以下操作
List<T[]> result = new List<T[]>();
// single combination
if (k == 0)
{
result.Add(new T[0]); // T is function type argument of generic function
如何在VB.NET中编写上面的最后一行?
我试过了:
result.Add(New T(0)) 'doesn't work!
答案 0 :(得分:1)
应该是:
result.Add(New T(0) {})
答案 1 :(得分:0)
我尝试了以下内容:
Dim A(0) As T ' Length = 1
Dim B As T() = New T(0) {} ' Length = 1
Dim C As T() = New T() {} ' Length = 0
Dim D As T() = New T(-1) {} ' Length = 0
Dim E(-1) As T ' Length = 0
Dim F As T() = Array.CreateInstance(GetType(T), 0) ' Length = 0
所以我建议第三个选项是最干净的。