title: from list to string with formatting
body: <p>i have a function getSelectedNumbers that take as input 3 list of number. after a manipulation i need to obtain a string in the format </p>
  
  <p>"[1_3,10,20,30,500],[1_1,2],[]"</p>
  
  <p>if the list is empty i need to have in the string the "[]" char </p>
  
  <p>i wrote the below function but i need to manage the empty case. </p>
  
  <p>Based on comment of Anu6is : 
  i was able to rewrite my code as below </p>
  
  <p>'''vb</p>
  
  <pre><code>Public Function getSelectedNumbers() As String          
          Dim selectedNumbers1 As IList(Of Element) =  repo.CanvasTerminalProduct.BoardDetails.Panel.pnlSuper3Panel1.Find(".//div[@class='selected']")
          Dim selectedNumbers2 As IList(Of Element) =  repo.CanvasTerminalProduct.BoardDetails.Panel.pnlSuper3Panel2.Find(".//div[@class='selected']")
          Dim selectedNumbers3 As IList(Of Element) =  repo.CanvasTerminalProduct.BoardDetails.Panel.pnlSuper3Panel3.Find(".//div[@class='selected']")
          Dim list1 As New List(Of String)
          Dim list2 As New List(Of String)
          Dim list3 As New List(Of String)
  
          For i As Integer = 0 To selectedNumbers1.Count -1
              list1.Add(selectedNumbers1(i).GetAttributeValue("innerText").ToString)
          Next i
          For i As Integer = 0 To selectedNumbers2.Count -1
              list2.Add(selectedNumbers2(i).GetAttributeValue("innerText").ToString)
          Next i
          For i As Integer = 0 To selectedNumbers3.Count -1
              list3.Add(selectedNumbers3(i).GetAttributeValue("innerText").ToString)
          Next i
  
          'Create List of List
          Dim selectedNumbersList As New List(Of List(Of String)) From {list1, list2, list3}
  
          Dim builder As New StringBuilder 'Used to build the output
          'Convert all the list in the correct string format using the join 
          For Each listX As List(Of String) In selectedNumbersList
              builder.Append("[1_").Append(String.Join(",", listX)).Append("],") 'String.Join() give you a comma delmited string
          Next
          'Remove the last, and the [1_] that are not needed
          Dim strSelectedNunmber As String = builder.ToString().TrimEnd(","c)         
          strSelectedNunmber = strSelectedNunmber.ToString().Replace("[1_]","[]")
  
          Return str
      End Function
  </code></pre>
  
  <p>'''</p>
  
  <p>now my question is there is a better way to generate the list1 list2 list3 ?</p>