开发者

C# VB.NET: How to make a jagged string array a public property

all i want to do is this:

    Public Property TabsCollection()() as String()()
        Get
            Return _tabsCollection
  开发者_如何转开发      End Get
        Set(ByVal value()() as String()())
            _tabsCollection = value
        End Set
    End Property

but it errors saying: End of statement expected.


TabsCollection()()

value()()

Public Property TabsCollection() As String()()
    Get
        Return _tabsCollection
    End Get
    Set(ByVal value As String()())
        _tabsCollection = value
    End Set
End Property


You have redundant pairs of parentheses:

Public Property TabsCollection() as String()()
    Get
        Return _tabsCollection
    End Get
    Set(ByVal value as String()())
        _tabsCollection = value
    End Set
End Property

Apart from that, don’t use arrays in that way. Arrays are (almost?) always wrong in a public interface of a class. Furthermore, the name suggests that what you have here is more aptly described by another data structure. A nested array of strings is a circumvention of proper strict typing.


Use this:

Public Property TabsCollection() as String()()
    Get
        Return _tabsCollection
    End Get
    Set(ByVal value as String()())
        _tabsCollection = value
    End Set
End Property
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜