Reputation: 1934
In vb.net when creating methods and properties I am creating methods using decimal parameters. There are other numeric types like short, long, double, etc.
Is there a simple way to create parameters that cover all numeric types in a single property/method without creating an overloaded property/method for each numeric type?
Upvotes: 0
Views: 101
Reputation: 9991
You can create generic functions/methods:
Public Function MyFunction(Of T As IConvertible)(value As T) As T
'Do something...
End Function
Public Sub MySub(Of T As IConvertible)(value As T)
'Do something...
End Sub
The following types implements the IConvertible interface:
Upvotes: 1