Need Linq Command: Convert String To Atrray

Mansour_Dalir 1,996 Reputation points
2023-06-05T12:52:00.54+00:00

hi

My String is

dim MyStt ="2 10,3 5,4 7"

Need to 2D Array

        Dim ResaultArray As Integer()() = New Integer(2)() {}
        ResaultArray (0) = New Integer() {2, 10}
        ResaultArray (1) = New Integer() {3, 5}
        ResaultArray (2) = New Integer() {4, 7}
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,768 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 119K Reputation points
    2023-06-05T13:28:24.1133333+00:00

    For example:

    Dim ResultArray As Integer()() = MyStt.Split(","c).Select(Function(p) p.Split(" "c, 3).Take(2).Select(Function(s) CInt(s)).ToArray).ToArray
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.