Switch enum auto-fill

后端 未结 9 2040
故里飘歌
故里飘歌 2020-12-24 00:23

I was typing a switch with an enum in VS 2013 and all case statements filled out automatically after I finished the switch. Now I can\'t repeat it. I was not hallucinating,

9条回答
  •  醉梦人生
    2020-12-24 00:37

    The selected answer is mostly correct, you don't need Resharper as other's have suggested (at least not with Visual Studio Professional 2012+).

    1) type "sw" then "[tab][tab]" (as Marvin Smit said)

    Which (as jmblack said) will generate something like:

      switch (switch_on)
      {
                default:
      }
    

    but then

    2) you need to select which thing to enumerate on (switch_on will be highlighted still at this point). So type in the Enum (or your variable of the enum type) while switch_on is highlited and hit [Enter][Enter].

    (I just confirmed this worked on my machine running VS2012, and i'm fairly certain this is the same thing i have done on my other machine running VS2013, and i haven't tested other versions of VS (ultimate/express/etc.))

提交回复
热议问题