Vb.NET 具有严格选项的体系结构

Vb.NET Architecture with Option Strict On

我会在选项 strict on 的情况下开始编码。我有一个 class 单元格,可以是数字、数据或字符串,包含在 class table 中。如何屏蔽 classes 中的类型处理?
起初我想到了一个接口,但是定义接口的 classes 必须具有完全相同的签名。

覆盖也是如此,我不能有不同的方法来区分自己只是为了 return 类型...

Option Strict On 是如何工作的?我必须 return 一个对象?

编辑: 现在 class 是:

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

但我认为在 Strict On 的上下文中应该不起作用。

 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

这里对问题进行了部分解释:

坚持使用 Object,但也许可以在 class 中添加一个 属性,告诉您在该单元格中实际使用的是什么类型:

 Public Interface ICell
    Property Value As Object
    Property DataType As Type
End Interface

尝试使用泛型。

Public Interface ICell(Of T)
    Property Value As T 
End Interface

Public Class cell(Of T)
    Implements ICell(Of T)
    Public Property Value As T Implements ICell(Of T).Value

    Public id As Long
    Public Formula As String
    Public ix As Integer
    Public lev As Integer
End Class

那么这两个都是正确的:

    Dim newCell As New cell(Of Double)
    Dim strCell As New cell(Of String)