Re: How to pass a 2-D array into a function?



Cool! I'm only on chapter 8 of my new .NET book (arrays don't make an appearance until chap 11) so that's very good news. I can throw away some of my bag of tricks.

Michael C wrote:
"Gman" <nah> wrote in message news:uz6JSwZ6FHA.3416@xxxxxxxxxxxxxxxxxxxxxxx

Ain't it?!  :-)

I keep an arsenal of functions for adding items to an array, returning an index in an array etc. to save me making myself dizzy by having to loop through arrays all the time.

As I understand it (and I may be guilty of spouting misinformation again here) Delphi has native methods to handle things like the above or allowing the easy deletion of an element in the middle of an array without having to load everything into a new array. VB.NET doesn't appear to have improved on arrays at all (other than eliminating 1 based arrays and allowing for one line declaration like Dim X() as long = (1,2,3,4) ... or something along those lines. While I guess using collections is feasible in some circumstances it's staggering that VB.NET still seems to fall short on something so fundamental. Oh... and there's also ArrayLists in .NET -- something I haven't looked at so maybe I should get off my high horse.


.net does have functions like this for arrays. You can do Array.IndexOf to find if an item exists. You can't add an element because arrays shouldn't really be sizable as they are a contiguous block of memory, if you need resizability the arraylist should be used. Lots of other functions have been added too such as sorting. C# doesn't have any way to redim an array like vb does as the redim is quite inefficient. In vb.net it creates a new array and copies the entire contents to the new array each time a redim is called.

Michael


.



Relevant Pages

  • Re: ReDim not working as expected. Array expert needed.
    ... with ReDim, so I commented out the ReDim statement, and ran the procedure to ... Dim MyArray As Variant ' Declare nonarray variant. ... array comes out dimensioned as ... Sub ArrayStudies3 differs from Sub ArrayStudies2 only in that MyArray ...
    (microsoft.public.excel.programming)
  • Re: Sub to extract uniques from 200k data in xl03
    ... The first returns an array of the unique elements of the input array; ... Dim i As Long, p As Object, q As String ... ReDim outputArrayTransposeTo UBound, _ ...
    (microsoft.public.excel.programming)
  • Re: Sub to extract uniques from 200k data in xl03
    ... The first returns an array of the unique elements of the input array; by default it is a case-sensitive, 1-based, vertical array. ... Dim i As Long, p As Object, q As String ... ReDim outputArrayTransposeTo UBound, _ ...
    (microsoft.public.excel.programming)
  • Re: ReDim an array AFTER its loaded into another array
    ... '.RteInfo2 as string 'etc depending on how many pieces of data you need ... Redim vRteFactsAy ... ' RFA is the route facts array ... Once a "master" array is formed, it looks like the component arrays ...
    (microsoft.public.excel.programming)
  • Re: Framework 2.0 array redim unsatisfactory performance
    ... I am not talking about "array redim" anymore. ... ReDim simply allocates a new ... but I do not even attempt to test its memory ...
    (microsoft.public.dotnet.languages.vb)

Loading