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. Enums, Intellisense, and switchs…

Enums, Intellisense, and switchs…

Scheduled Pinned Locked Moved C#
visual-studioquestioncsharphelp
13 Posts 7 Posters 2 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.
  • M Matthew Klein

    What is the format needed for Intellisense to pick up on my comments for my enums? So when I type “MyEnum.ItemOne” the intellisense will display the documentation I’ve written for “ItemOne”? Also, is there some sort of command I can use in Visual Studio that will generate a compile error if I don’t use all possible Enum values in a switch statement? I’m looking for a compile-time dummy catch incase I add an extra Enum value later but might miss a statement that should switch on all possible values of the Enum. Thanks!

    L Offline
    L Offline
    Luc Pattyn
    wrote on last edited by
    #3

    Anticast wrote:

    a compile error if I don’t use all possible Enum values

    nope. you could come up with extra code that performs some checks, but it isn't straightforward. :)

    Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


    I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.


    1 Reply Last reply
    0
    • M Matthew Klein

      What is the format needed for Intellisense to pick up on my comments for my enums? So when I type “MyEnum.ItemOne” the intellisense will display the documentation I’ve written for “ItemOne”? Also, is there some sort of command I can use in Visual Studio that will generate a compile error if I don’t use all possible Enum values in a switch statement? I’m looking for a compile-time dummy catch incase I add an extra Enum value later but might miss a statement that should switch on all possible values of the Enum. Thanks!

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #4

      If you use "tab tab" for the switch it will automatically put in all cases

      D B 2 Replies Last reply
      0
      • L Lost User

        If you use "tab tab" for the switch it will automatically put in all cases

        D Offline
        D Offline
        Dan Mos
        wrote on last edited by
        #5

        that's a good one. i had no ideea. thanks:thumbsup:

        L 1 Reply Last reply
        0
        • D Dan Mos

          that's a good one. i had no ideea. thanks:thumbsup:

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #6

          I didn't know this until recently, when I did it by accident - imagine the chances of that happening ! :)

          M D 2 Replies Last reply
          0
          • D Dan Mos
            /// <summary>
            /// Absolutely
            /// </summary>
            public enum Blah
            {
                /// <summary>
                /// The Absolete System.Terror
                /// </summary>
                Terror,
                /// <summary>
                /// Liquid.Nitrogen
                /// </summary>
                Nitro
            }
            

            [Edit]Fixed "<" signs For Point 2: Not that I know of. But It shouldn't be too hard to create a method that checks each enumeration used. [/Edit]

            M Offline
            M Offline
            Matthew Klein
            wrote on last edited by
            #7

            Thanks, works perfectly! I was trying variations on

            public enum MyEnum
            {
            ItemOne //My notes
            }

            with no success =/

            D 1 Reply Last reply
            0
            • L Lost User

              I didn't know this until recently, when I did it by accident - imagine the chances of that happening ! :)

              M Offline
              M Offline
              Matthew Klein
              wrote on last edited by
              #8

              I agree, thanks for the tip!

              1 Reply Last reply
              0
              • L Lost User

                I didn't know this until recently, when I did it by accident - imagine the chances of that happening ! :)

                D Offline
                D Offline
                Dan Mos
                wrote on last edited by
                #9

                cool :-D

                1 Reply Last reply
                0
                • M Matthew Klein

                  Thanks, works perfectly! I was trying variations on

                  public enum MyEnum
                  {
                  ItemOne //My notes
                  }

                  with no success =/

                  D Offline
                  D Offline
                  Dan Mos
                  wrote on last edited by
                  #10

                  what the System.Terror? It sure does. If you mess with it you're f... :)

                  modified on Friday, March 5, 2010 6:33 PM

                  1 Reply Last reply
                  0
                  • L Lost User

                    If you use "tab tab" for the switch it will automatically put in all cases

                    B Offline
                    B Offline
                    BryanWilkins
                    wrote on last edited by
                    #11

                    I had no idea! Real cool! :thumbsup:

                    -Bryan My latest programming adventure was coding the multimedia features for the Rip Ride Rockit coaster at Universal Studios Florida. I love my job.

                    1 Reply Last reply
                    0
                    • M Matthew Klein

                      What is the format needed for Intellisense to pick up on my comments for my enums? So when I type “MyEnum.ItemOne” the intellisense will display the documentation I’ve written for “ItemOne”? Also, is there some sort of command I can use in Visual Studio that will generate a compile error if I don’t use all possible Enum values in a switch statement? I’m looking for a compile-time dummy catch incase I add an extra Enum value later but might miss a statement that should switch on all possible values of the Enum. Thanks!

                      R Offline
                      R Offline
                      RCoate
                      wrote on last edited by
                      #12

                      You may want to check out GhostDoc[^] It is a free add on for Visual Studio that makes documenting stuff (for Intellisense or not) realy easy. Ctl+Shift+d while the insertion point is in your enum and all of the ///<summary></summary> tags for each option are inserted (and the stuff at the top). I am a bit of a fan since I found it.

                      1 Reply Last reply
                      0
                      • M Matthew Klein

                        What is the format needed for Intellisense to pick up on my comments for my enums? So when I type “MyEnum.ItemOne” the intellisense will display the documentation I’ve written for “ItemOne”? Also, is there some sort of command I can use in Visual Studio that will generate a compile error if I don’t use all possible Enum values in a switch statement? I’m looking for a compile-time dummy catch incase I add an extra Enum value later but might miss a statement that should switch on all possible values of the Enum. Thanks!

                        realJSOPR Offline
                        realJSOPR Offline
                        realJSOP
                        wrote on last edited by
                        #13

                        Putting all enums in a switch statement simply because they exist is pointless. There are MANY times when you simply don't care about 1 or more of the ordinals (lumping their handling into the default: clause).

                        .45 ACP - because shooting twice is just silly
                        -----
                        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                        -----
                        "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

                        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