I would begin to code with option strict on. I have a class Cell, that can be, numeric,data or string, included in a class table. How do can mask the type handling inside the classes?
At first I thought at an Interface, but the classes that define the interface must have exactly the same signature.
The same for an override , I can not have different methods that differentiate themselves just for return type...
How does Option Strict On works? I must return an Object?
Edit: Now the class is :
Public Class cell
Private pvalue As Object
Public id As Long
Public Formula As String
Public ix As Integer
Public lev As Integer
Public Property Value() As Object
Get
Return pvalue
End Get
Set(ByVal value As Object)
pvalue = value
End Set
End Property
End Class
But I think that in an context of Strict On should not work.
Public Interface ICell
Property Value() ' I must define an univoque datatype
End Interface
Public dClass cell
Implements ICell
Private pvalue As Object
Public id As Long
Public Formula As String
Public ix As Integer
Public lev As Integer
Public Property Value() As Date Implements ICell.Value
Get
Return pvalue
End Get
Set(ByVal value As date)
pvalue = value
End Set
End Property
End Class
Public Class cell
Implements ICell
Private pvalue As double
Public id As Long
Public Formula As String
Public ix As Integer
Public lev As Integer
Public Property Value() As double Implements ICell.Value
Get
Return pvalue
End Get
Set(ByVal value As Double)
pvalue = value
End Set
End Property
End Class
The problem get explained partially here :improve the exception handling vb.net
Try using Generics.
Then both of these are correct: