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. Comparing enums?

Comparing enums?

Scheduled Pinned Locked Moved C#
tutorialquestion
13 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.
  • K kumar bs

    Hello All, How to compare two enum types? Thanks

    R Offline
    R Offline
    Ravenet
    wrote on last edited by
    #3

    use the typeof(ur enum) with compare() method

    Cheers,Earn and Enjoy RRave MCTS,MCPD http://ravesoft.blogspot.com

    C 1 Reply Last reply
    0
    • R Ravenet

      use the typeof(ur enum) with compare() method

      Cheers,Earn and Enjoy RRave MCTS,MCPD http://ravesoft.blogspot.com

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

      How would that work, exactly ?

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      R 1 Reply Last reply
      0
      • C Christian Graus

        How would that work, exactly ?

        Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        R Offline
        R Offline
        Ravenet
        wrote on last edited by
        #5

        Good question i have put small exmaple here public enum Named : int { A, B, C, D } public enum Names : byte { A, B, C, D } check if (Enum.Equals(typeof(Named),typeof(Names))) { //type is equal } thanks you

        Cheers,Earn and Enjoy RRave MCTS,MCPD http://ravesoft.blogspot.com

        C A 2 Replies Last reply
        0
        • R Ravenet

          Good question i have put small exmaple here public enum Named : int { A, B, C, D } public enum Names : byte { A, B, C, D } check if (Enum.Equals(typeof(Named),typeof(Names))) { //type is equal } thanks you

          Cheers,Earn and Enjoy RRave MCTS,MCPD http://ravesoft.blogspot.com

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

          OK - so does that compare based on enum name, or their intrinsic int value ?

          Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          R 1 Reply Last reply
          0
          • C Christian Graus

            OK - so does that compare based on enum name, or their intrinsic int value ?

            Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

            R Offline
            R Offline
            Ravenet
            wrote on last edited by
            #7

            I seen your profile,your are MVP in code project, Are you checking me? :-D Basically Compare based on the type of the enum You can understand from my example. Thank you

            Cheers,Earn and Enjoy RRave MCTS,MCPD http://ravesoft.blogspot.com

            C 1 Reply Last reply
            0
            • R Ravenet

              I seen your profile,your are MVP in code project, Are you checking me? :-D Basically Compare based on the type of the enum You can understand from my example. Thank you

              Cheers,Earn and Enjoy RRave MCTS,MCPD http://ravesoft.blogspot.com

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

              No, I've never seen this before, I would think that comparing two different enums is a bad design, I'm curious how it would work.

              Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

              R 1 Reply Last reply
              0
              • C Christian Graus

                No, I've never seen this before, I would think that comparing two different enums is a bad design, I'm curious how it would work.

                Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                R Offline
                R Offline
                Ravenet
                wrote on last edited by
                #9

                So is it wrong? or is it can't be exist like that?

                Cheers,Earn and Enjoy RRave MCTS,MCPD http://ravesoft.blogspot.com

                C 1 Reply Last reply
                0
                • R Ravenet

                  So is it wrong? or is it can't be exist like that?

                  Cheers,Earn and Enjoy RRave MCTS,MCPD http://ravesoft.blogspot.com

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

                  I am saying I've never used it, I was curious how it works, although I'd never use it, personally.

                  Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                  R 1 Reply Last reply
                  0
                  • C Christian Graus

                    I am saying I've never used it, I was curious how it works, although I'd never use it, personally.

                    Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                    R Offline
                    R Offline
                    Ravenet
                    wrote on last edited by
                    #11

                    Thank you.

                    Cheers,Earn and Enjoy RRave MCTS,MCPD http://ravesoft.blogspot.com

                    1 Reply Last reply
                    0
                    • R Ravenet

                      Good question i have put small exmaple here public enum Named : int { A, B, C, D } public enum Names : byte { A, B, C, D } check if (Enum.Equals(typeof(Named),typeof(Names))) { //type is equal } thanks you

                      Cheers,Earn and Enjoy RRave MCTS,MCPD http://ravesoft.blogspot.com

                      A Offline
                      A Offline
                      AndrewVos
                      wrote on last edited by
                      #12

                      You're trying to compare the types to each other. The enum Equals takes two enum values.


                      www.wickedorange.com www.andrewvos.com

                      A 1 Reply Last reply
                      0
                      • A AndrewVos

                        You're trying to compare the types to each other. The enum Equals takes two enum values.


                        www.wickedorange.com www.andrewvos.com

                        A Offline
                        A Offline
                        AndrewVos
                        wrote on last edited by
                        #13

                        *The enum Equals can take two enum values


                        www.wickedorange.com www.andrewvos.com

                        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