Intellisense – Enum, Switch Statement

November 6, 2009

I noticed a nice little gem today in Visual Studio 2008  – When using a Switch statement with an enum, visual studio will create the Switch statement for you with all possible options.

Now, I should confess, I managed to accidently cause this to happen once, I’ve just tried so I could post exactly how its done (i.e. At what point Visual Studio says ‘Hi, looks like your writing a switch statement based on an enum’ (Cue the crazy paperclip/hash mark) but I just could not get it to work again!

So – If you know how/why/when this works…Please let me know! :o)



2 Responses to “Intellisense – Enum, Switch Statement”

  1. joelabrown said

    Type: “switch” + Tab + Tab to insert the switch snippet. Type the name of the enum variable you want to switch on to replace the snippet’s “switch_on” placeholder and then press Enter. The cases will be generated automatically.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: