Stoica Nicusor
Stoica Nicusor

Reputation: 211

VB.NET List(Of String) to Long()

how do I convert a List(Of String) to Long() ? I have this :

    Dim List As New List(Of String)
    List.Add("0044001")
    List.Add("0044002")
    List.Add("0044003")

And I need to convert it to Long() because function parameter is "long[] msisdns" (C# library), I can do New Long() {0044001,0044002,0044003} but it is not what i want , or how do I add to the Long array ? Thanks in advance !

Upvotes: 0

Views: 2070

Answers (1)

Jacob Krall
Jacob Krall

Reputation: 28825

Use LINQ:

Dim Longs = (From s In List
             Select Convert.ToInt64(s)).ToArray()

If you don't want to use LINQ,

Dim Longs2 = List.ConvertAll(AddressOf Convert.ToInt64).ToArray

Upvotes: 3

Related Questions