0

I'm working more than 5 hours on a freaking simple problem I have using Highcharts.NET Basically all I want to do, is to initiate an array with dynamic data.

I really want to have only this part "{1500,3}" being added from an object, string, list or what ever to the array.

If I'm creating a string with the values "{1500,3}" it tells me of course, that 1 dimension of the array is missing.

This is the part, I need to have dynamically with values from a list / string etc.

  TokioData = New Object(,) {{1500, 3}}
zvaenr
  • 59
  • 2
  • 11
  • 1
    What is dynamic data in your case? Could you give an example? Do you need a string to parse (what is the format?) into 2d array? – Dmitry Bychenko Mar 28 '14 at 14:54
  • 1
    If you want to create and modify 2D arrays see: http://www.dotnetperls.com/2d-array But please clarify your question, as in its current form it's not really answerable - if there is such a word – qqbenq Mar 28 '14 at 15:01
  • nobody ? :( what a pity – zvaenr Mar 28 '14 at 18:44

2 Answers2

0

I would recommend using a list over an array, especially if you want to add / remove values later in your code:

    Dim TokioData As New List(Of KeyValuePair(Of Integer, Integer))
    TokioData.Add(New KeyValuePair(Of Integer, Integer)(1500, 3))
    TokioData.Add(New KeyValuePair(Of Integer, Integer)(1700, 5))
    TokioData.Add(New KeyValuePair(Of Integer, Integer)(1800, 13))

One of the great thing about lists are that you don't have to re-declare the size when adding values like you do with an array. There is also built in functionality if you need to convert that list to an array:

    TokioData.ToArray()
Force
  • 3,288
  • 1
  • 13
  • 19
  • Believe me, I would never ever use arrays over list. But as I'm using this for highcharts, I need to put this in this freaking object(,) array. – zvaenr Mar 28 '14 at 15:23
-1

in c# you could use dynamic keyword, but not sure if this exist in VB, but here is link about dynamics

Community
  • 1
  • 1
Medet Tleukabiluly
  • 11,662
  • 3
  • 34
  • 69