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
  1. Home
  2. General Programming
  3. C#
  4. declaring object array

declaring object array

Scheduled Pinned Locked Moved C#
data-structureshelpquestion
8 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.
  • W Offline
    W Offline
    wasimsharp
    wrote on last edited by
    #1

    hi freind i need help. i m developing an application and i declare a class and i need the array of the object o that particular class how can i declare it:^)

    wasim khan

    G C K 3 Replies Last reply
    0
    • W wasimsharp

      hi freind i need help. i m developing an application and i declare a class and i need the array of the object o that particular class how can i declare it:^)

      wasim khan

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

      List CollectionOfYourClassObjects = new List(); Should do it for you.

      -- Cheers, Gary http://www.garyshort.org

      G C 2 Replies Last reply
      0
      • W wasimsharp

        hi freind i need help. i m developing an application and i declare a class and i need the array of the object o that particular class how can i declare it:^)

        wasim khan

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        You would do better to use a List, as you can add and remove items from it. List Otherwise, you would do myClass[] coll = new myClass[10] ( for example, to create an array of 10 items ). Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        1 Reply Last reply
        0
        • G garyshort

          List CollectionOfYourClassObjects = new List(); Should do it for you.

          -- Cheers, Gary http://www.garyshort.org

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          You need to check 'Ignore HTML tags in this message (good for code snippets)' if you want to use < or > in your posts.

          Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          G 1 Reply Last reply
          0
          • G garyshort

            List CollectionOfYourClassObjects = new List(); Should do it for you.

            -- Cheers, Gary http://www.garyshort.org

            G Offline
            G Offline
            garyshort
            wrote on last edited by
            #5

            Grr bloody formating... I'll try again... List CollectionOfYourClassObjects = new List(); -- Cheers, Gary http://www.garyshort.org

            1 Reply Last reply
            0
            • W wasimsharp

              hi freind i need help. i m developing an application and i declare a class and i need the array of the object o that particular class how can i declare it:^)

              wasim khan

              K Offline
              K Offline
              kapil bhatnagar
              wrote on last edited by
              #6

              use this logic: ClassName[] obj = null; obj = new ClassName[size]; :)

              1 Reply Last reply
              0
              • C Christian Graus

                You need to check 'Ignore HTML tags in this message (good for code snippets)' if you want to use < or > in your posts.

                Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                G Offline
                G Offline
                garyshort
                wrote on last edited by
                #7

                Thanks Christian! :-)

                -- Cheers, Gary http://www.garyshort.org

                C 1 Reply Last reply
                0
                • G garyshort

                  Thanks Christian! :-)

                  -- Cheers, Gary http://www.garyshort.org

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #8

                  *grin* no problem.

                  Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                  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