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. Array question!

Array question!

Scheduled Pinned Locked Moved C#
csharpdata-structuresquestion
8 Posts 5 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

    Migrating VB6 code to C#..... VB6 Dim coefficients() As Double coefficients = LeastFit(myData, order, False, 0, 0, 1) c# double[] coefficients; coefficients = LeastFit(myData, order, false, 0, 0, 1); The question is, is this OK in c#. It compiles OK but I'm assuming it will choke at run time because of the array size.

    G D 2 Replies Last reply
    0
    • C C NewBe

      Migrating VB6 code to C#..... VB6 Dim coefficients() As Double coefficients = LeastFit(myData, order, False, 0, 0, 1) c# double[] coefficients; coefficients = LeastFit(myData, order, false, 0, 0, 1); The question is, is this OK in c#. It compiles OK but I'm assuming it will choke at run time because of the array size.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Why? What's wrong with the array size?

      --- Year happy = new Year(2007);

      C 1 Reply Last reply
      0
      • G Guffa

        Why? What's wrong with the array size?

        --- Year happy = new Year(2007);

        C Offline
        C Offline
        C NewBe
        wrote on last edited by
        #3

        The array size is missing. The array is being returned from the function.

        M G 2 Replies Last reply
        0
        • C C NewBe

          The array size is missing. The array is being returned from the function.

          M Offline
          M Offline
          Martin 0
          wrote on last edited by
          #4

          Hello, In this case the array instance is made in the method, so you dont have to care about the size of the array. All the best, Martin

          C 1 Reply Last reply
          0
          • M Martin 0

            Hello, In this case the array instance is made in the method, so you dont have to care about the size of the array. All the best, Martin

            C Offline
            C Offline
            C NewBe
            wrote on last edited by
            #5

            Thanks Martin I expected the compiler to cough...now I know why.

            1 Reply Last reply
            0
            • C C NewBe

              The array size is missing. The array is being returned from the function.

              G Offline
              G Offline
              Guffa
              wrote on last edited by
              #6

              What you are declaring is only a reference to an array, and it's always declared without a size. The size is determined when the array object is created. For example: double[] values; // declares a reference values = new double[42]; // creates an array and assigns the reference

              --- Year happy = new Year(2007);

              E 1 Reply Last reply
              0
              • G Guffa

                What you are declaring is only a reference to an array, and it's always declared without a size. The size is determined when the array object is created. For example: double[] values; // declares a reference values = new double[42]; // creates an array and assigns the reference

                --- Year happy = new Year(2007);

                E Offline
                E Offline
                Ed Poore
                wrote on last edited by
                #7

                Guffa wrote:

                Year happy = new Year(2007);

                I like :-D


                I have no idea what I just said. But my intentions were sincere.

                Poore Design

                1 Reply Last reply
                0
                • C C NewBe

                  Migrating VB6 code to C#..... VB6 Dim coefficients() As Double coefficients = LeastFit(myData, order, False, 0, 0, 1) c# double[] coefficients; coefficients = LeastFit(myData, order, false, 0, 0, 1); The question is, is this OK in c#. It compiles OK but I'm assuming it will choke at run time because of the array size.

                  D Offline
                  D Offline
                  David Domingues
                  wrote on last edited by
                  #8

                  You can also try to use Arraylists.

                  Contact me! Please feel free to visit my site

                  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