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. Pass enum through methods

Pass enum through methods

Scheduled Pinned Locked Moved C#
helptutorial
6 Posts 3 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
    Deresen
    wrote on last edited by
    #1

    Hello everyone, I'm trying to make an questionnaire and I want to do this with enums. For example: enum Color{ Black, White } enum Height{ cm_10, cm_20 } With this information I want to show each enum in a panel, where you first have to answer the color and then the height, and it has to be extendable. But I don't get it working. Can you help me, I would like to do it something as following:

    private void askQuestion(Enum e)
    {
    String[] ss = Enum.GetNames(typeof(e));
    putOnScreen(ss);
    }
    private void overall()
    {
    ArrayList ar = new ArrayList();
    ar.Add(Color);
    ar.Add(Height);
    foreach(Enum e in ar)
    {
    askQuestion(e);
    }
    }

    I guess it should be possible, but I don't know how.

    P 1 Reply Last reply
    0
    • D Deresen

      Hello everyone, I'm trying to make an questionnaire and I want to do this with enums. For example: enum Color{ Black, White } enum Height{ cm_10, cm_20 } With this information I want to show each enum in a panel, where you first have to answer the color and then the height, and it has to be extendable. But I don't get it working. Can you help me, I would like to do it something as following:

      private void askQuestion(Enum e)
      {
      String[] ss = Enum.GetNames(typeof(e));
      putOnScreen(ss);
      }
      private void overall()
      {
      ArrayList ar = new ArrayList();
      ar.Add(Color);
      ar.Add(Height);
      foreach(Enum e in ar)
      {
      askQuestion(e);
      }
      }

      I guess it should be possible, but I don't know how.

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

      If you put your questions inside enumerations, you haven't got an extensible mechanism. When I've developed this type of application in the past, I've always used a database. Roughly, this breaks down into: Topics Questions Answers AnswerTypes (textbox, multi-select, etc) Scores for answer This makes for a much more extensible questionnaire application.

      "WPF has many lovers. It's a veritable porn star!" - Josh Smith

      My blog | My articles | MoXAML PowerToys

      D 1 Reply Last reply
      0
      • P Pete OHanlon

        If you put your questions inside enumerations, you haven't got an extensible mechanism. When I've developed this type of application in the past, I've always used a database. Roughly, this breaks down into: Topics Questions Answers AnswerTypes (textbox, multi-select, etc) Scores for answer This makes for a much more extensible questionnaire application.

        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

        My blog | My articles | MoXAML PowerToys

        D Offline
        D Offline
        Deresen
        wrote on last edited by
        #3

        You are totaly right about that. I'm going to make it with a database. But if we asume that I would do it the way I described above (just to learn something), is this possible or possible but not done or something else?

        P P 2 Replies Last reply
        0
        • D Deresen

          You are totaly right about that. I'm going to make it with a database. But if we asume that I would do it the way I described above (just to learn something), is this possible or possible but not done or something else?

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

          It's possible - but not advisable. BTW - using ArrayList isn't a good idea. I assume you're not saddled with developing in .NET 1 or 1.1.

          "WPF has many lovers. It's a veritable porn star!" - Josh Smith

          My blog | My articles | MoXAML PowerToys

          D 1 Reply Last reply
          0
          • P Pete OHanlon

            It's possible - but not advisable. BTW - using ArrayList isn't a good idea. I assume you're not saddled with developing in .NET 1 or 1.1.

            "WPF has many lovers. It's a veritable porn star!" - Josh Smith

            My blog | My articles | MoXAML PowerToys

            D Offline
            D Offline
            Deresen
            wrote on last edited by
            #5

            I'm used to developing in .NET 2.0 and 3.5 ArrayList was just a suggestion, I prefer just arrays, like Enum[] e = { enum1, enum2 }; But that didn't work. If you say I shouldn't use it, I'll just go and work with a database.

            1 Reply Last reply
            0
            • D Deresen

              You are totaly right about that. I'm going to make it with a database. But if we asume that I would do it the way I described above (just to learn something), is this possible or possible but not done or something else?

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              Or an XML file.

              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