StringCollection.Add Method adds a string to the end of the StringCollection. : StringCollection « Data Structure « VB.Net






StringCollection.Add Method adds a string to the end of the StringCollection.

 


Imports System
Imports System.Collections
Imports System.Collections.Specialized

Public Class SamplesStringCollection
   Public Shared Sub Main()
      Dim myCol As New StringCollection()
      Dim myArr() As [String] = {"RED", "orange", "yellow", "RED", "green"}
      myCol.AddRange(myArr)
      PrintValues(myCol)
   End Sub 
   Public Shared Sub PrintValues(myCol As IEnumerable)
      Dim obj As [Object]
      For Each obj In  myCol
         Console.WriteLine("   {0}", obj)
      Next obj
   End Sub 

End Class 

   
  








Related examples in the same category

1.StringCollection.Clear Method removes all the strings from the StringCollection.
2.StringCollection.Contains Method determines whether the specified string is in the StringCollection.
3.StringCollection.CopyTo Method copies StringCollection values to a one-dimensional array
4.Adds a range of elements from an array to the end of the StringCollection