如果它是基于0的,我们如何添加占位符以使其基于1?谢谢.
它基于0.回归问题可能是:你为什么要让它以1为基础?
使用扩展方法,您可以(如果您愿意)执行:
Public Function GetOneBased(Of T)(ByVal list As IList(Of T), ByVal index As Integer) As T Return list(index-1) End Function Public Sub SetOneBased(Of T)(ByVal list As IList(Of T), ByVal index As Integer, ByVal value As T) list(index-1) = value End Sub
然后使用(几乎任何收藏):
Dim foo = data.GetOneBased(1) data.SetOneBased(1, bar)