DataTable or Array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • twq@hispeed.ch

    #1

    DataTable or Array

    Hello

    I would like to populate a 2-dimensional array with different
    datatyps , 1. dimension is always a String, 2. dimension could be of
    Typ Double or String.

    What would be the better solution performance wise, to create an
    String Array and then try to Convert the 2. Dimension into either
    double or String, or to create an Datatable with Double & String
    Columns, or is there any other way to do it?

    Thank you in advance

  • Cor Ligthert [MVP]

    #2
    Re: DataTable or Array

    Hi,

    Forget the performance or you should be interested in parts of picoseconds.

    Take that which fits you the best and is the best maintanable afterwards.

    Mostly I take direct a datatable, because with that I get a lot of extra
    methods which I don't have at the array.

    But feel free to do it in another way as you are more used with arrays.

    Cor

    <twq@hispeed.ch schreef in bericht
    news:1171361955 .171077.257300@ a34g2000cwb.goo glegroups.com.. .
    Hello
    >
    I would like to populate a 2-dimensional array with different
    datatyps , 1. dimension is always a String, 2. dimension could be of
    Typ Double or String.
    >
    What would be the better solution performance wise, to create an
    String Array and then try to Convert the 2. Dimension into either
    double or String, or to create an Datatable with Double & String
    Columns, or is there any other way to do it?
    >
    Thank you in advance
    >

    Comment

    • twq@hispeed.ch

      #3
      Re: DataTable or Array

      thank you very much for your quick response,

      Best regards
      Tobias

      Comment

      • twq@hispeed.ch

        #4
        Re: DataTable or Array

        Follow up question,

        How would you implement a Datatable as a Property of Class where the
        Table would have 5 specified columns?

        thanks

        Comment

        • RobinS

          #5
          Re: DataTable or Array


          <twq@hispeed.ch wrote in message
          news:1171373806 .734018.226710@ v45g2000cwv.goo glegroups.com.. .
          Follow up question,
          >
          How would you implement a Datatable as a Property of Class where the
          Table would have 5 specified columns?
          >
          thanks
          >
          You can just add it as a property, and then create it and/or populate it in
          your constructor. Here's an example.


          Public Class Car

          Private _ColorTable As DataTable
          Property ColorTable() As DataTable
          Get
          Return _ColorTable
          End Get
          Set(byVal value As ColorTable)
          _ColorTable = value
          End Set
          End Property

          Public Sub New()
          CreateColorTabl e()
          End Sub

          Private Sub CreateColorTabl e()
          'This creates a new datatable. You could just as
          ' easily read it in from a data source.
          ' I wasn't sure which method you were using.
          Dim ct as New DataTable()
          ct.Columns.Add( "Red", GetType(Integer ))
          ct.Columns.Add( "Blue", GetType(Integer ))
          ct.Columns.Add( "Green", GetType(Integer ))
          ct.Columns.Add( "Hue", GetType(Integer ))
          ct.Columns.Add( "ColorName" , GetType(String) )
          ColorTable = ct
          End Sub

          End Class


          Robin S.
          Ts'i mahnu uterna ot twan ot geifur hingts uto.


          Comment

          • dbahooker@hotmail.com

            #6
            Re: DataTable or Array

            use an array

            ADO.net is about ready for another 'Visual Fred' moment and you don't
            want to have to rewrite everything every 2 years



            On Feb 13, 2:19 am, "t...@hispeed.c h" <t...@hispeed.c hwrote:
            Hello
            >
            I would like to populate a 2-dimensional array with different
            datatyps , 1. dimension is always a String, 2. dimension could be of
            Typ Double or String.
            >
            What would be the better solution performance wise, to create an
            String Array and then try to Convert the 2. Dimension into either
            double or String, or to create an Datatable with Double & String
            Columns, or is there any other way to do it?
            >
            Thank you in advance

            Comment

            Working...