S
Simon Woods
Hi
Further to my previous question ...
Is it possible to set up a declaration using generics which permits the
specification of any numeric value rather than a formal division between
integers and floats
I want to set up a generic definition for Adding 2 numbers
Public Function Add(Byval x as Integer, Byval y as Integer) as Integer
Public Function Add(Byval x as Double, Byval y as Double) as Double
Really I think I'm wanting something like
Public Function Add(Byval x as INumeric, Byval y as INumeric) as INumeric
but I'm not sure how to implement this without wrapping every number
into some sort of class?
BTW I don't think I want
Public Function Add(Of T)(Byval x as T, Byval y as T) as T
because you need to know up-front the type of number
e.g.
Dim a as Integer =Add(of Integer)(1 + 1)
Dim b as Double = Add(of Double)(1.1 + 1.1)
Thx
S
Further to my previous question ...
Is it possible to set up a declaration using generics which permits the
specification of any numeric value rather than a formal division between
integers and floats
I want to set up a generic definition for Adding 2 numbers
Public Function Add(Byval x as Integer, Byval y as Integer) as Integer
Public Function Add(Byval x as Double, Byval y as Double) as Double
Really I think I'm wanting something like
Public Function Add(Byval x as INumeric, Byval y as INumeric) as INumeric
but I'm not sure how to implement this without wrapping every number
into some sort of class?
BTW I don't think I want
Public Function Add(Of T)(Byval x as T, Byval y as T) as T
because you need to know up-front the type of number
e.g.
Dim a as Integer =Add(of Integer)(1 + 1)
Dim b as Double = Add(of Double)(1.1 + 1.1)
Thx
S