简体   繁体   中英

Renaming functions in visual studio 2015 for C#

We just migrated to visual studio 2015. We were using 2010 and with 2010, I was able to hit f2 and type a new name for a function/variable and it would apply to all instances. Now in vs 2015 when I hit f2 there is no where to type the name to rename the variable/method to. Sorry if this sounds silly but I have been puzzling now a couple daze...

I believe in 2015, you simply need to rename the variable where it is, and you'll see a dotted box or line appear around your variable, you can right click and do "Rename variable" which will rename it everywhere it's used. Same with methods.

我相信还有其他重命名绑定:

Ctrl + R, Ctrl + R

You can right-click over the function name and choose Refactor > Rename and go from there. It will ask you if you want to apply it solution-wide and allow you to preview as well.

Edit - this is the same as @TheLethalCoder answer, just not keyboard shortcut

TheLethalCoder is correct. Put your cursor on the class/method/variable name and hit

Ctrl + R, Ctrl + R

and you'll be prompted for the new name and shown a list of places in your code base that it'll be changed.

For VS 2015 onwards, the renaming is

CTRL +. for renaming.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM