Switch enum auto-fill

后端 未结 9 2110
故里飘歌
故里飘歌 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:47

    Notice: This answer applies to performing the switch/enum autogeneration while also using Resharper.

    Using Visual Studio 2013 and Resharper 8.2, the previously mentioned methods do not work. Here's how to actually get this generation to work when using Resharper. Hopefully it will save someone the fifteen minutes I just spent figuring this out.

    Performing "sw(tab)(tab)" will only generate the following:

    switch (nameOfEnumVariable)
    {
    
    }
    

    Resharper can generate the labels using Alt + Enter (if your cursor stands in the switch statement) and selecting Generate switch labels as in the following screenshot:


    Using the Resharper menu to fill in a switch statement


    The result looks like this:


    enter image description here


提交回复
热议问题