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


This is the code that I am trying to develop:

  public structure Data T) Get T Return Retrieve Interval (ByVal Value T) as Low Belt T as Public Sub-New (ByVal pValue as t) maxStat = pValue curStat = pValue End Sub Public Property Level () As) curStat = value if CurStat & gt; MaxStat then curStat = maxStat End Set End Property End Structure  

This will not compile because I am getting an error that is not defined for '>' type T and T. Anyway, can I specify the barriers that T is of a numerical type?

After the changes and suggestions made by the users to me this is what it is still not working. Do I have to change the values ​​of T for all those who are IC Comparable? Public structural data (TK ICempereble (TK)) as the DM position in the form of DM maxestate T, in the form of T sub form byeVal pValue) maxStat = pValue curStat = pValue End Sub Public Property Get the return as Statistic () T. Set up the set and set (ByVal Value as T) if the value & gt; Maxstat then End and End End End and Endure and Structure

Here you ... Should work. Public structure data (i.e. asymptotic) in the form of t (dimensional) position as low status in the form of public sub-new (ByVal pValue as T) maxStat = pValue curStat = PValue End Sub Public Retrieve Level as Property () T Get Stretch End (byVal Value as T) curStat = value if curStat.CompareTo (maxStat) & gt; 0 then curstat = maxstat end set end property end structure

In addition, you have mentioned the barrier on numerics, but I do not think you can just stop on it. You can however restrict the primitive types (on the stack) and by doing so, the object does not allow (on the heap): public structure figure (T as {structure, IComparable}) .


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -