Generic Classes (T) - Specifying from a Range of Types VB.Net

后端 未结 2 838
温柔的废话
温柔的废话 2021-01-22 09:08

This is the code I\'m trying to develop:

  Public Structure Statistic(Of t)
        Dim maxStat As t
        Dim curStat As t

        Public Sub New(ByVal pValu         


        
2条回答
  •  粉色の甜心
    2021-01-22 09:51

    You could constrain T to IComparable. That way you know that curStat and maxStat both have a CompareTo method you can use to determine if one is greater than the other.

提交回复
热议问题