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. need something like enumerated classes.

need something like enumerated classes.

Scheduled Pinned Locked Moved C#
6 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.
  • D Offline
    D Offline
    dino2094
    wrote on last edited by
    #1

    I need something like an enumeration of classes. class Garage{ public static Car Ford = new Car (.....); public static Car Chevy = new Car (.....); public static Car Subaru = new Car (.....); public static Car Mazda = new Car (.....); } then do something like foreach(Car x in Garage){ ... ... } Funny thing: By force of habit, I hit F6 after I typed this..;P

    Mike HankeyM C 2 Replies Last reply
    0
    • D dino2094

      I need something like an enumeration of classes. class Garage{ public static Car Ford = new Car (.....); public static Car Chevy = new Car (.....); public static Car Subaru = new Car (.....); public static Car Mazda = new Car (.....); } then do something like foreach(Car x in Garage){ ... ... } Funny thing: By force of habit, I hit F6 after I typed this..;P

      Mike HankeyM Offline
      Mike HankeyM Offline
      Mike Hankey
      wrote on last edited by
      #2

      Use a collection. public static Car = nll; ArrayList list = new ArrayList(); Ford = new Car (.....); list.Add(Ford); foreach(Car c in Garage) ....... Mike

      If you keep doing what you've been doing you'll keep getting what you've been getting!

      C 1 Reply Last reply
      0
      • Mike HankeyM Mike Hankey

        Use a collection. public static Car = nll; ArrayList list = new ArrayList(); Ford = new Car (.....); list.Add(Ford); foreach(Car c in Garage) ....... Mike

        If you keep doing what you've been doing you'll keep getting what you've been getting!

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

        Mike Hankey wrote:

        ArrayList list = new ArrayList();

        But only in C# 1.1, otherwise, use generic collections.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "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 )

        Mike HankeyM 1 Reply Last reply
        0
        • D dino2094

          I need something like an enumeration of classes. class Garage{ public static Car Ford = new Car (.....); public static Car Chevy = new Car (.....); public static Car Subaru = new Car (.....); public static Car Mazda = new Car (.....); } then do something like foreach(Car x in Garage){ ... ... } Funny thing: By force of habit, I hit F6 after I typed this..;P

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

          dino2094 wrote:

          public static Car Ford = new Car (.....); public static Car Chevy = new Car (.....); public static Car Subaru = new Car (.....); public static Car Mazda = new Car (.....);

          Wouldn't it make more sense to have a collection of car types, as derived classes ? Can't you ever have more than one Mazda in your garage ?

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "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 )

          C 1 Reply Last reply
          0
          • C Christian Graus

            Mike Hankey wrote:

            ArrayList list = new ArrayList();

            But only in C# 1.1, otherwise, use generic collections.

            Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "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 )

            Mike HankeyM Offline
            Mike HankeyM Offline
            Mike Hankey
            wrote on last edited by
            #5

            Yes..Thank You I'm still converting from VS2002 to VS2005 , its taking awhile? Mike

            If you keep doing what you've been doing you'll keep getting what you've been getting!

            1 Reply Last reply
            0
            • C Christian Graus

              dino2094 wrote:

              public static Car Ford = new Car (.....); public static Car Chevy = new Car (.....); public static Car Subaru = new Car (.....); public static Car Mazda = new Car (.....);

              Wouldn't it make more sense to have a collection of car types, as derived classes ? Can't you ever have more than one Mazda in your garage ?

              Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "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 )

              C Offline
              C Offline
              Colin Angus Mackay
              wrote on last edited by
              #6

              Christian Graus wrote:

              Can't you ever have more than one Mazda in your garage ?

              Or even more than one Mazda in all garages (note, he's declared them as static)


              Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: Introduction to AJAX (2nd May), SQL Server, Mock Objects My website

              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