找到一个例子,我不明白它的意思。
如何使用相同的代码从 DataRow 或 DataReader 读取数据?
我不知道如何转换接口和两个类以响应 C#?
编辑:这是我要转换为 C# 的代码:
Interface IIndexer
Default ReadOnly Property Item(ByVal index As String)
End Interface
Class DataReaderWrapper
Implements IIndexer
Private ReadOnly _reader As IDataReader
Public Sub New(reader As IDataReader)
_reader = reader
End Sub
Public ReadOnly Property Item(index As String) As Object Implements IIndexer.Item
Get
Return _reader(index)
End Get
End Property
End Class
Class DataRowWrapper
Implements IIndexer
Private ReadOnly _row As DataRow
Public Sub New(row As DataRow)
_row = row
End Sub
Public ReadOnly Property Item(index As String) As Object Implements IIndexer.Item
Get
Return _row(index)
End Get
End Property
End Class