Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Redim multiD-Array

Redim multiD-Array

Scheduled Pinned Locked Moved C#
questioncsharpdata-structures
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    C NewBe
    wrote on last edited by
    #1

    Since Redim does not exist in C#, How do I convert this in C#? Dim basePoints() As Double ReDim basePoints(AUTO_PTS - 1, 1)

    P E D 3 Replies Last reply
    0
    • C C NewBe

      Since Redim does not exist in C#, How do I convert this in C#? Dim basePoints() As Double ReDim basePoints(AUTO_PTS - 1, 1)

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Use one of the Collection classes which is designed for better array handling. Take a look at classes like the ArrayList to see how they help.

      Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world." Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that." Deja View - the feeling that you've seen this post before.

      1 Reply Last reply
      0
      • C C NewBe

        Since Redim does not exist in C#, How do I convert this in C#? Dim basePoints() As Double ReDim basePoints(AUTO_PTS - 1, 1)

        E Offline
        E Offline
        ednrgc
        wrote on last edited by
        #3

        There is no equivalent. You can do it yourself with something like this (unchecked, but you get the idea):

        double[] NewBasePoints = new double[newsize + 1];
        if (thisArray != null)
        System.Array.Copy(thisArray, NewBasePoints, System.Math.Min(thisArray.Length, NewBasePoints.Length));
        BasePoints = NewBasePoints;

        D 1 Reply Last reply
        0
        • C C NewBe

          Since Redim does not exist in C#, How do I convert this in C#? Dim basePoints() As Double ReDim basePoints(AUTO_PTS - 1, 1)

          D Offline
          D Offline
          Dave Doknjas
          wrote on last edited by
          #4

          (via Instant C#) double[] basePoints = null; basePoints = new double[AUTO_PTS,2]; ReDim Preserve is a little trickier, but also has a C# equivalent.

          David Anton www.tangiblesoftwaresolutions.com Instant C#: VB to C# converter Instant VB: C# to VB converter Instant C++: C# to C++ converter, VB to C++ converter Instant Python: VB to Python converter

          1 Reply Last reply
          0
          • E ednrgc

            There is no equivalent. You can do it yourself with something like this (unchecked, but you get the idea):

            double[] NewBasePoints = new double[newsize + 1];
            if (thisArray != null)
            System.Array.Copy(thisArray, NewBasePoints, System.Math.Min(thisArray.Length, NewBasePoints.Length));
            BasePoints = NewBasePoints;

            D Offline
            D Offline
            Dave Doknjas
            wrote on last edited by
            #5

            You're thinking of 'ReDim Preserve'. The OP was dealing with the simpler 'ReDim'.

            David Anton www.tangiblesoftwaresolutions.com Instant C#: VB to C# converter Instant VB: C# to VB converter Instant C++: C# to C++ converter, VB to C++ converter Instant Python: VB to Python converter

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups