Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert array to generic list?

Status
Not open for further replies.

serializer

Programmer
May 15, 2006
143
SE
I have these properties below but I don't know the best way for ? = converting array to generic list:


<ComVisible(False)> Public Conditions As New List(Of String)


Public Property ConditionsArray() As String()
Get
Return Conditions.ToArray
End Get
Set(ByVal value As String())
Conditions = ?
End Set
End Property
 
Code:
dim s(0 to 10) as String
Dim l As System.Collections.Generic.List(Of String) = New System.Collections.Generic.List(Of String)()
l.AddRange(s)

Exploiting the fact that DotNet arrays implement IEnumerable, and that Generic List's AddRange method takes one...

Of course, this is not a cast - so updating the array won't be reflected in the list...

mmilan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top