1

Good evening,

I'm working since 8 hours on a simple ASP.net Chart Website (dotnet highcharts.com) and I'm having incredible trouble with the following:

I have to add a series to a chart with an 2 dimensional array of Object. So I can't use anything else.

This is how it looks right now, with hardcoded values:

  TokioData = New Object(,) {{1500, 3},{1700, 5}}

I only need to have the {value1, value2} part being added from a list / string or whatever.

But I can't get it to work ... I'm really not having any idea, as I'm googling the whole day, just to find out how to add KeyValuePairs to an 2D-Array.

1 Answer 1

1

You can do that without array initializer syntax. First, initiate 2D array with minimum required size. Then use simple For loop to add each data from list to 2D array. For example :

'list where data stored initially
Dim list As New List(Of KeyValuePair(Of Integer, Integer)) _
    From
    {
        New KeyValuePair(Of Integer, Integer)(1500, 3),
        New KeyValuePair(Of Integer, Integer)(1700, 5)
    }

Dim TokioData As Object(,)
'initate empty 2D array with size just enough to store all data from list
TokioData = New Object(list.Count - 1, 1) {}
'add data from list to 2D array
For i As Integer = 0 To list.Count-1
    TokioData(i, 0) = list(i).Key
    TokioData(i, 1) = list(i).Value
Next
Sign up to request clarification or add additional context in comments.

1 Comment

You sir, are a freaking legend!!! Thank you sooo much there. Exactly what I was looking for :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.