C#VB.NET:如何使锯齿状字符串数组的公共属性

问题描述:

所有我想做的事情是这样的:C#VB.NET:如何使锯齿状字符串数组的公共属性

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

但它错误说:语句结束的预期。

TabsCollection()()

值()()

你有多余的对括号:

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

除此之外,不以这种方式使用数组。在一个类的公共接口中,数组总是(几乎?)总是错误的。此外,这个名字表明,你在这里的内容更适合用另一个数据结构来描述。一个嵌套的字符串数组是对适当的严格打字的规避。

使用此:

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