0

Hello this is my first time posting so bear with me if I'm not so on point. Here is my question:

I'm trying to create a list within a list in asp.net, something like

 callList(a).part(b).Number
 callList(a).part(b).Desc

I have service calls and each of these calls can have multiple parts listed in them. Right now the class structure is something like

 public class calls

 somevars.....

      public class part

           public Number as integer
           public desc as String

       end class
 end class

To create the call themselves I have

 callList As New List(Of calls)
 callList.add(calls)

How would I add multiple parts for each call?

4

2 回答 2

1

我认为您要查找的内容在嵌套列表下进行了描述(ASP.net 与 VB.net 的轻微语法更改) 将列表添加到 vb.net 中的另一个列表中


编辑:如果您对链接有疑问,您会发现:

希望这可以帮助

更新阅读它们就像访问任何其他列表一样。要获取第一条记录中的第一个字段,请返回 records(0)(0)

第一条记录中的第二个字段返回记录(0)(1)

等等 。. .

Dim listRecord As New List(Of String) 
listRecord.Add(txtRating.Text)
listRecord.Add(txtAge.Text) 
listRace.Add(listRecord)

Dim records as new List(of List(of String)) 
records.Add(listRecord)

他创建了一个

List(Of String)

然后将其添加到

List(Of List(Of String))
于 2013-11-10T23:26:28.047 回答
1

也许这就是你要找的。我用了不同的名字,但你会明白的:)

    Public Class clsContent
        Public Name As String
        Public listOfCounteries As List(Of clsCountry)
    End Class

    Public Class clsCountry
        Public countryName As String
    End Class

    Class Program
        Private Shared Sub Main(args As String())

            Dim _countryEgypt As New clsCountry()
            _countryEgypt.countryName = "Egypt"

            Dim _countrySudan As New clsCountry()
            _countrySudan.countryName = "Sudan"

            Dim _cont As New clsContent()
            _cont.Name = "Africa"
            _cont.listOfCounteries = New List(Of clsCountry)()
            _cont.listOfCounteries.Add(_countryEgypt)
            _cont.listOfCounteries.Add(_countrySudan)


            Dim _listOfContenents As New List(Of clsContent)()
            _listOfContenents.Add(_cont)


            Console.WriteLine((("Contenent: " + _listOfContenents(0).Name & " Country 1: ") + _listOfContenents(0).listOfCounteries(0).countryName & " Country 2: ") + _listOfContenents(0).listOfCounteries(1).countryName)


    Console.Read()
    End Sub
End Class
于 2013-11-11T00:12:53.643 回答