PC Review


Reply
Thread Tools Rate Thread

DataTable or Array

 
 
twq@hispeed.ch
Guest
Posts: n/a
 
      13th Feb 2007
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

 
Reply With Quote
 
 
 
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      13th Feb 2007
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

<(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
twq@hispeed.ch
Guest
Posts: n/a
 
      13th Feb 2007
thank you very much for your quick response,

Best regards
Tobias

 
Reply With Quote
 
twq@hispeed.ch
Guest
Posts: n/a
 
      13th Feb 2007
Follow up question,

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

thanks

 
Reply With Quote
 
RobinS
Guest
Posts: n/a
 
      13th Feb 2007

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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()
CreateColorTable()
End Sub

Private Sub CreateColorTable()
'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.


 
Reply With Quote
 
dbahooker@hotmail.com
Guest
Posts: n/a
 
      14th Feb 2007
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.ch" <t...@hispeed.ch> wrote:
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Add array to a datatable =?Utf-8?B?YQ==?= Microsoft C# .NET 3 7th May 2005 09:15 AM
How can I use real SQL on a DataTable? i.e. not array of rows using a filter... as in DataTable.Select Dan V. Microsoft C# .NET 3 1st Jul 2004 03:06 PM
Re: array or datatable AlexS Microsoft C# .NET 0 11th May 2004 09:41 PM
Re: array or datatable Ignacio Machin \( .NET/ C# MVP \) Microsoft C# .NET 0 11th May 2004 06:52 PM
Re: How do I get a datatable as an array Hermit Dave Microsoft ASP .NET 2 5th Feb 2004 04:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:17 PM.